#include "Memory2_lib.h"
#include <vector>
void Solve(int T, int N){
while(T--) {
std::vector<int> ans(2*N, -1);
int x = 0, y = 1, z = -1;
int lastComp = Flip(x, y);
for(int i = 2; i < 2*N; i++) {
int xComp = Flip(i, x);
int yComp = Flip(i, y);
if(z == -1) {
if(xComp == lastComp && yComp != lastComp) {
lastComp = yComp;
x = i;
}
else if(yComp == lastComp && xComp != lastComp) {
lastComp = xComp;
y = i;
}
else if(xComp == lastComp && yComp == lastComp) {
z = i;
}
}
else {
if(xComp == lastComp && yComp == lastComp) {
ans[x] = ans[y] = lastComp;
x = z;
y = i;
z = -1;
lastComp = Flip(x, y);
}
else if(xComp == lastComp && yComp != lastComp) {
x = i;
z = -1;
lastComp = yComp;
}
else if(xComp != lastComp && yComp == lastComp) {
y = i;
z = -1;
lastComp = xComp;
}
}
}
ans[x] = ans[y] = lastComp;
std::vector<std::vector<int> > output(N);
for(int i = 0; i < 2*N; i++) {
if(ans[i] == -1)
ans[i] = Flip(x, i);
output[ans[i]].push_back(i);
}
for(int i = 0; i < N; i++)
Answer(output[i][0], output[i][1], i);
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
4 ms |
128 KB |
Output is correct |
2 |
Correct |
5 ms |
384 KB |
Output is correct |
3 |
Correct |
4 ms |
384 KB |
Output is correct |
4 |
Correct |
5 ms |
384 KB |
Output is correct |
5 |
Correct |
4 ms |
384 KB |
Output is correct |
6 |
Correct |
4 ms |
384 KB |
Output is correct |
7 |
Correct |
5 ms |
256 KB |
Output is correct |
8 |
Correct |
4 ms |
256 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
4 ms |
256 KB |
Wrong Answer[2] |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
5 ms |
256 KB |
Wrong Answer[2] |
2 |
Halted |
0 ms |
0 KB |
- |