diff options
author | Jérémy Zurcher <jeremy@asynk.ch> | 2022-03-25 09:38:27 +0100 |
---|---|---|
committer | Jérémy Zurcher <jeremy@asynk.ch> | 2022-03-25 09:38:27 +0100 |
commit | 701b6b88ac8258a5c21197bb726825e7592d762b (patch) | |
tree | 524c08cb7602d62fc40dc34783a973cbb78339d0 /05-advanced_algorithms_and_complexity/03-np-completness/03-budget_allocation | |
parent | 623c5d60f54c62fd50d115859cf60ea41785d5d2 (diff) | |
download | coursera-701b6b88ac8258a5c21197bb726825e7592d762b.zip coursera-701b6b88ac8258a5c21197bb726825e7592d762b.tar.gz |
Algorithms : add 05-advanced_algorithms_and_complexity 03-np-completness
Diffstat (limited to '05-advanced_algorithms_and_complexity/03-np-completness/03-budget_allocation')
-rw-r--r-- | 05-advanced_algorithms_and_complexity/03-np-completness/03-budget_allocation/budget_allocation.cpp | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/05-advanced_algorithms_and_complexity/03-np-completness/03-budget_allocation/budget_allocation.cpp b/05-advanced_algorithms_and_complexity/03-np-completness/03-budget_allocation/budget_allocation.cpp new file mode 100644 index 0000000..d2bfc51 --- /dev/null +++ b/05-advanced_algorithms_and_complexity/03-np-completness/03-budget_allocation/budget_allocation.cpp @@ -0,0 +1,43 @@ +#include <ios> +#include <iostream> +#include <vector> + +using namespace std; + +struct ConvertILPToSat { + vector< vector<int> > A; + vector<int> b; + + ConvertILPToSat(int n, int m) : A(n, vector<int>(m)), b(n) + {} + + void printEquisatisfiableSatFormula() { + // This solution prints a simple satisfiable formula + // and passes about half of the tests. + // Change this function to solve the problem. + cout << "3 2" << endl; + cout << "1 2 0" << endl; + cout << "-1 -2 0" << endl; + cout << "1 -2 0" << endl; + } +}; + +int main() { + ios::sync_with_stdio(false); + + int n, m; + cin >> n >> m; + ConvertILPToSat converter(n, m); + for (int i = 0; i < n; i++) { + for (int j = 0; j < m; j++) { + cin >> converter.A[i][j]; + } + } + for (int i = 0; i < n; i++) { + cin >> converter.b[i]; + } + + converter.printEquisatisfiableSatFormula(); + + return 0; +} |