Submission #26116

#TimeUsernameProblemLanguageResultExecution timeMemory
26116kajebiiiMemory 2 (JOI16_memory2)C++14
100 / 100
0 ms2024 KiB
#include "Memory2_lib.h" #include <bits/stdc++.h> using namespace std; #define REP(i,n) for(int (i)=0;(i)<(int)(n);(i)++) #define REPO(i,n) for(int (i)=1; (i)<=(int)(n); (i)++) #define SZ(v) ((int)(v).size()) #define ALL(v) (v).begin(),(v).end() #define one first #define two second typedef long long ll; typedef pair<int, int> pi; const int INF = 0x3f2f1f0f; const ll LINF = 1ll * INF * INF; const int MAX_N = 55; vector<pi> Val[MAX_N]; queue<int> Same; void Solve(int T, int N){ for(int i=0; i<N; i++) { int val = Flip(i*2, i*2+1); Val[val].push_back(pi(i*2, i*2+1)); } for(int i=0; i<N; i++) if(SZ(Val[i]) == 2) Same.push(i); while(!Same.empty()) { int v = Same.front(); Same.pop(); pi a = Val[v][0], b = Val[v][1]; int aa[2] = {a.one, a.two}, bb[2] = {b.one, b.two}; for(int i=0; i<2; i++) for(int j=0; j<2; j++) { int val = Flip(aa[i], bb[j]); if(val != v) { Val[val].push_back(pi(aa[i], bb[j])); if(SZ(Val[val]) == 2) Same.push(val); Answer(aa[1-i], bb[1-j], v); } } } for(int i=0; i<N; i++) if(SZ(Val[i]) == 1) Answer(Val[i][0].one, Val[i][0].two, i); return; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...