Submission #112042

#TimeUsernameProblemLanguageResultExecution timeMemory
112042TexTangMemory 2 (JOI16_memory2)C++14
100 / 100
17 ms404 KiB
#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 (stderr)

memory2.cpp: In function 'void Solve(int, int)':
memory2.cpp:13:6: warning: unused variable 'index' [-Wunused-variable]
  int index = 0, q[3], flipped[2*N][2*N], a = 0, b = 0, c = 0;
      ^~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...