This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |