Submission #167838

#TimeUsernameProblemLanguageResultExecution timeMemory
167838TAISA_Memory 2 (JOI16_memory2)C++14
100 / 100
2 ms376 KiB
#include "Memory2_lib.h" #include <bits/stdc++.h> using namespace std; void Solve(int T, int N) { vector<int> vis(2 * N), res(2 * N), co(N); for (int i = 0; i < 2 * N; i++) { if (vis[i]) { continue; } vector<int> c(N), r(2 * N); bool f = true; for (int j = i + 1; j < 2 * N; j++) { if (vis[j]) { continue; } r[j] = Flip(i, j); c[r[j]]++; if (co[r[j]] + c[r[j]] > 2) { f = false; for (int k = i + 1; k < j; k++) { if (vis[k]) { continue; } if (r[k] != r[j]) { res[k] = r[k]; vis[k] = 1; co[r[k]]++; } } res[i] = r[j]; vis[i] = 1; co[r[j]]++; break; } } if (f) { for (int j = i + 1; j < 2 * N; j++) { if (vis[j]) { continue; } res[j] = r[j]; co[r[j]]++; } for (int j = 0; j < N; j++) { if (co[j] == 1) { res[i] = j; break; } } break; } } vector<vector<int>> v(N); for (int i = 0; i < 2 * N; i++) { v[res[i]].push_back(i); } for (int i = 0; i < N; i++) { // cout << v[i][0] << " " << v[i][1] << endl; Answer(v[i][0], v[i][1], i); } return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...