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;
int N;
int A[110];
int M[110][110];
int ask(int x, int y){
if (x > y) swap(x, y);
if (M[x][y] != -1) return M[x][y];
return M[x][y] = Flip(x, y);
}
void Solve(int T, int N){
if (N == 1){
Answer(0, 1, 0);
return;
}
memset(M, -1, sizeof M);
memset(A, -1, sizeof A);
int a=0, b=1, c=-1, t=2;
while (t<2*N){
if (c == -1){
c = t++;
if (ask(a, b) == ask(b, c) && ask(b, c) == ask(c, a)) continue;
if (ask(a, b) == ask(a, c)){
A[a] = ask(a, b);
a=c, c=-1;
}
else if (ask(b, a) == ask(b, c)){
A[b] = ask(a, b);
b=c, c=-1;
}
else{
A[c] = ask(a, c);
c=-1;
}
}
else{
if (ask(a, t) == ask(b, t) && ask(b, t) == ask(c, t)){
A[t] = ask(a, t);
t++;
}
else if (ask(a, t) == ask(b, t)){
A[a] = A[b] = ask(a, t);
a = c, b = t;
c = -1, t++;
}
else if (ask(b, t) == ask(c, t)){
A[b] = A[c] = ask(b, t);
b = t;
c = -1, t++;
}
else{
A[a] = A[c] = ask(a, t);
a = t;
c = -1, t++;
}
}
}
for (int i=0; i<N; i++){
int x=-1, y=-1;
for (int j=0; j<2*N; j++){
if (A[j] == i){
if (x == -1) x = j;
else y = j;
}
}
if (x == -1){
for (int j=0; j<2*N; j++){
if (A[j] == -1){
if (x == -1) x = j;
else y = j;
}
}
}
Answer(x, y, i);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |