# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
112042 | 2019-05-17T07:04:31 Z | TexTang | None (JOI16_memory2) | C++14 | 17 ms | 404 KB |
#include "Memory2_lib.h" #include <iostream> #include <vector> #include <list> using namespace std; void Solve(int T, int N){ vector <int> res[N]; srand (time(NULL)); list <int> qe; for(int i = 0;i < 2*N;i++) qe.push_back(i); int index = 0, q[3], flipped[2*N][2*N], a = 0, b = 0, c = 0; for(int i = 0;i < 2*N;i++) for(int j = 0;j < 2*N;j++) flipped[i][j] = 0; for(int i = 0;i < 3 && i < 2*N;i++){ q[i] = qe.front(); qe.pop_front(); } while(!qe.empty()){ if(!(a == b && b == c)){ qe.pop_front(); } if(flipped[q[0]][q[1]]) a = flipped[q[0]][q[1]]; else a = flipped[q[0]][q[1]] = Flip(q[0],q[1]); if(flipped[q[1]][q[2]]) b = flipped[q[1]][q[2]]; else b = flipped[q[1]][q[2]] = Flip(q[1],q[2]); if(flipped[q[0]][q[2]]) c = flipped[q[0]][q[2]]; else c = flipped[q[0]][q[2]] = Flip(q[0],q[2]); if(a == b && b == c){ int o = rand() % 3; qe.push_back(q[o]); q[o] = qe.front(); qe.pop_front(); continue; } if(a == b){ res[a].push_back(q[1]); if(qe.empty()) q[1] = q[2]; else q[1] = qe.front(); } else if (a == c) { res[c].push_back(q[0]); if(qe.empty()) q[0] = q[1], q[1] = q[2]; else q[0] = qe.front(); } else if (b == c) { res[b].push_back(q[2]); q[2] = qe.front(); } } a = flipped[q[0]][q[1]]; if(res[a].size() == 0){ res[a].push_back(q[0]); res[a].push_back(q[1]); } for(int i = 0;i < N;i++){ Answer(res[i][0], res[i][1], i); } }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 256 KB | Output is correct |
2 | Correct | 2 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 3 ms | 384 KB | Output is correct |
5 | Correct | 3 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 3 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 384 KB | Output is correct |
2 | Correct | 5 ms | 384 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 2 ms | 404 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 3 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 384 KB | Output is correct |
2 | Correct | 2 ms | 364 KB | Output is correct |
3 | Correct | 2 ms | 384 KB | Output is correct |
4 | Correct | 2 ms | 384 KB | Output is correct |
5 | Correct | 17 ms | 384 KB | Output is correct |
6 | Correct | 2 ms | 384 KB | Output is correct |
7 | Correct | 2 ms | 384 KB | Output is correct |
8 | Correct | 2 ms | 384 KB | Output is correct |
9 | Correct | 2 ms | 384 KB | Output is correct |
10 | Correct | 2 ms | 384 KB | Output is correct |