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"
int w[220][220], R[220][2], RC[220];
int Get(int a, int b) {
if (w[a][b] == 0) {
int t = Flip(a, b);
w[a][b] = w[b][a] = t + 1;
}
return w[a][b] - 1;
}
void Solve(int T, int N){
if (N == 1) {
Answer(0, 1, 0);
return;
}
Get(0, 1);
int i, t1 = 0, t2 = 1, t3 = -1;
for (i = 2; i < 2*N; i++) {
if (t3 == -1) {
int c1 = Get(t1, t2);
int c2 = Get(t1, i);
int c3 = Get(t2, i);
if (c1 == c2&&c2 == c3) {
t3 = i;
continue;
}
else {
if (c1 == c2) {
R[c1][RC[c1]++] = t1;
t1 = i;
}
else if (c1 == c3) {
R[c1][RC[c1]++] = t2;
t2 = i;
}
else {
R[c2][RC[c2]++] = i;
}
}
}
else {
int cc = Get(t1, t2);
int c1 = Get(t1, i);
int c2 = Get(t2, i);
int cnt = (cc == c1) + (cc == c2);
if (cnt == 0) {
R[c1][RC[c1]++] = i;
}
else {
int c3 = Get(t3, i);
if (cc == c1)R[cc][RC[cc]++] = t1;
if (cc == c2)R[cc][RC[cc]++] = t2;
if (cc == c3)R[cc][RC[cc]++] = t3;
if (cc != c1)t2 = t1;
if (cc != c2)t2 = t2;
if (cc != c3)t2 = t3;
t1 = i;
t3 = -1;
}
}
}
for (i = 0; i < N; i++) {
if (RC[i] == 0)Answer(t1, t2, i);
else Answer(R[i][0], R[i][1], 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... |