Submission #39783

#TimeUsernameProblemLanguageResultExecution timeMemory
39783aomeMemory 2 (JOI16_memory2)C++14
100 / 100
1 ms2068 KiB
#include <bits/stdc++.h> #include "Memory2_lib.h" using namespace std; const int N = 105; int res[N]; int f[N][N]; int cnt[N]; bool vis[N]; vector<int> v; void Solve(int T, int n) { memset(f, -1, sizeof f); memset(res, -1, sizeof res); if (n == 1) { Answer(0, 1, 0); return; } for (int i = 0; i < 3; ++i) v.push_back(i); for (int i = 0; i < 3; ++i) { for (int j = 0; j < i; ++j) { f[i][j] = f[j][i] = Flip(i, j); } } for (int i = 3; i < 2 * n; ++i) { for (int j = 0; j < 3; ++j) { f[i][v[j]] = f[v[j]][i] = Flip(i, v[j]); } v.push_back(i); for (int j = 0; j < 4; ++j) { int tmp = -1; bool flag = 0; for (int k = 0; k < 4; ++k) { if (k == j) continue; if (tmp == -1) tmp = f[v[j]][v[k]]; if (tmp != f[v[j]][v[k]]) flag = 1; } if (!flag) { res[v[j]] = tmp; vector<int> _v = v; v.clear(); for (int k = 0; k < 4; ++k) { if (k == j) continue; v.push_back(_v[k]); } break; } } } // for (int i = 0; i < n * 2; ++i) cout << res[i] << ' '; cout << '\n'; for (int i = 0; i < n * 2; ++i) { if (res[i] == -1) continue; for (int j = i + 1; j < n * 2; ++j) { if (res[j] == -1) continue; if (res[i] == res[j]) Answer(i, j, res[j]), vis[res[j]] = 1; } } int pos = -1; for (int i = 0; i < n * 2; ++i) { if (res[i] != -1 && !vis[res[i]]) pos = i; } for (int i = 0; i < 3; ++i) { for (int j = 0; j < i; ++j) { if (f[v[i]][v[j]] != res[pos]) { Answer(v[i], v[j], f[v[i]][v[j]]); for (int k = 0; k < 3; ++k) { if (k != i && k != j) { Answer(pos, v[k], res[pos]); } } } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...