# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
172778 |
2020-01-02T15:34:28 Z |
songc |
None (JOI16_memory2) |
C++14 |
|
6 ms |
400 KB |
#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 |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
1 ms |
380 KB |
Output is correct |
8 |
Correct |
3 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
6 ms |
376 KB |
Output is correct |
2 |
Correct |
3 ms |
368 KB |
Output is correct |
3 |
Correct |
3 ms |
376 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
0 ms |
376 KB |
Output is correct |
6 |
Correct |
0 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
364 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
2 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
376 KB |
Output is correct |
2 |
Correct |
2 ms |
376 KB |
Output is correct |
3 |
Correct |
2 ms |
400 KB |
Output is correct |
4 |
Correct |
2 ms |
376 KB |
Output is correct |
5 |
Correct |
2 ms |
376 KB |
Output is correct |
6 |
Correct |
2 ms |
376 KB |
Output is correct |
7 |
Correct |
2 ms |
396 KB |
Output is correct |
8 |
Correct |
2 ms |
376 KB |
Output is correct |
9 |
Correct |
1 ms |
376 KB |
Output is correct |
10 |
Correct |
2 ms |
376 KB |
Output is correct |