Submission #250936

#TimeUsernameProblemLanguageResultExecution timeMemory
250936imeimi2000Memory 2 (JOI16_memory2)C++17
100 / 100
1 ms384 KiB
#include "Memory2_lib.h" #include <vector> using namespace std; struct asks { int a, b; }; vector<asks> mp[50]; void Solve(int T, int n) { for (int i = 0; i < n; ++i) { mp[Flip(i << 1, i << 1 | 1)].push_back({ i << 1, i << 1 | 1 }); } vector<int> two; for (int i = 0; i < n; ++i) { if (mp[i].size() == 2) two.push_back(i); } while (!two.empty()) { int t = two.back(); two.pop_back(); asks p = mp[t][0]; asks q = mp[t][1]; int x = Flip(p.a, q.a); int y = Flip(p.a, q.b); int z = Flip(p.b, q.a); int w = Flip(p.b, q.b); if (x != t) { Answer(p.b, q.b, t); mp[x].push_back({ p.a, q.a }); if (mp[x].size() == 2) two.push_back(x); } else if (y != t) { Answer(p.b, q.a, t); mp[y].push_back({ p.a, q.b }); if (mp[y].size() == 2) two.push_back(y); } else if (z != t) { Answer(p.a, q.b, t); mp[z].push_back({ p.b, q.a }); if (mp[z].size() == 2) two.push_back(z); } else if (w != t) { Answer(p.a, q.a, t); mp[w].push_back({ p.b, q.b }); if (mp[w].size() == 2) two.push_back(w); } mp[t].clear(); } for (int i = 0; i < n; ++i) { if (mp[i].size()) Answer(mp[i][0].a, mp[i][0].b, i); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...