# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
843732 | 2023-09-04T13:33:16 Z | mickey080929 | None (JOI16_memory2) | C++14 | 1 ms | 604 KB |
#include "Memory2_lib.h" #include <bits/stdc++.h> using namespace std; int ret[110]; int cnt[110]; int chk[110]; int chk2[110]; vector<int> ans[110]; void Solve(int T, int N) { mt19937 gen(3141592); uniform_int_distribution<int> dis(0, 1'000'000'000); int r = 2 * N; int r2 = 2 * N; while (true) { if (r == 2) { int x = -1, y = -1; for (int i=0; i<2*N; i++) { if (!chk[i]) { if (x == -1) x = i; else y = i; } } ans[Flip(x, y)] = {x, y}; break; } assert(r2 >= 1); int idx = dis(gen) % r2; int pv; for (int i=0; i<2*N; i++) { if (!chk2[i]) { if (idx == 0) { pv = i; break; } idx --; } } chk2[pv] = 1; r2 --; for (int i=0; i<N; i++) cnt[i] = 0; for (int i=0; i<2*N; i++) { if (pv == i || chk[i]) continue; ret[i] = Flip(pv, i); cnt[ret[i]] ++; } int cur = -1; for (int i=0; i<N; i++) { if (cnt[i] & 1) { cur = i; break; } } for (int i=0; i<2*N; i++) { if (pv == i || chk[i]) continue; if (ret[i] != cur) { ans[ret[i]].push_back(i); chk[i] = 1; chk2[i] = 1; r --; r2 --; } } } for (int i=0; i<N; i++) { Answer(ans[i][0], ans[i][1], i); } return; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 604 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 604 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Runtime error | 1 ms | 604 KB | Execution killed with signal 6 |
2 | Halted | 0 ms | 0 KB | - |