# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1004247 | 2024-06-21T06:48:12 Z | aykhn | Trobojnica (COCI19_trobojnica) | C++17 | 433 ms | 524288 KB |
#include <bits/stdc++.h> using namespace std; #define inf 0x3F3F3F3F3F3F3F3F const int MXN = 20 + 5; const int mod = 1e9 + 7; const int LOG = 20; int n; vector<array<int, 3>> res; int ok(vector<array<int, 3>> &v) { if (v.size() == 3) { return v[0][0] != v[1][0] && v[0][0] != v[2][0] && v[1][0] != v[2][0]; } for (int i = 0; i < v.size(); i++) { if (v[i][0] != v[(i + 1) % n][0]) { vector<array<int, 3>> nw; for (int j = 0; j < v.size(); j++) { if (j != i && j != (i + 1) % n) { nw.push_back(v[j]); } else if (j == i) { nw.push_back({6 - v[i][0] - v[(i + 1) % n][0], v[i][1], v[(i + 1) % n][2]}); } } if (ok(nw)) { res.push_back({v[i][1], v[(i + 1) % n][2], 6 - v[i][0] - v[(i + 1) % n][0]}); return 1; } } } return 0; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cin >> n; vector<array<int, 3>> v; for (int i = 0; i < n; i++) { char ch; cin >> ch; v.push_back({ch - '0', i + 1, (i + 1) % n + 1}); } if (!ok(v)) cout << "NE\n"; else { cout << "DA\n"; for (array<int, 3> &x : res) cout << x[0] << ' ' << x[1] << ' ' << x[2] << '\n'; } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 433 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 433 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 433 ms | 524288 KB | Execution killed with signal 9 |
2 | Halted | 0 ms | 0 KB | - |