제출 #471847

#제출 시각아이디문제언어결과실행 시간메모리
471847dennisstarMemory 2 (JOI16_memory2)C++17
0 / 100
1 ms204 KiB
#include "Memory2_lib.h" #include <bits/stdc++.h> using namespace std; void Solve(int t, int n) { vector<int> val(2*n, -1); vector<vector<int>> st(n); priority_queue<int> pq; for (int i=0; i<2*n; i++) pq.emplace(i); while (pq.size()) { int x=pq.top(); pq.pop(); while (pq.size()) { int y=pq.top(); pq.pop(); int r=Flip(x, y); if (st[r].size()==2) { val[x]=r; pq.emplace(y); for (auto &i:st[r]) pq.emplace(i); for (int i=0; i<n; i++) { if (i!=r) for (auto &j:st[i]) val[j]=i; st[i].clear(); } break; } st[r].emplace_back(y); } } for (int i=0; i<2*n; i++) if (val[i]!=-1) st[val[i]].emplace_back(i); int lx=2*n*(2*n-1); for (auto &i:st) for (auto &j:i) lx-=j; for (int i=0; i<n; i++) { if (st[i].size()==1) st[i].emplace_back(lx); Answer(st[i][0], st[i][1], i); } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...