Submission #628985

#TimeUsernameProblemLanguageResultExecution timeMemory
628985welleythMinerals (JOI19_minerals)C++17
40 / 100
22 ms1872 KiB
#include "minerals.h" #include <vector> #include <fstream> void Solve(int N) { int col[2*N+1]; for(int i = 0; i < 2*N+1; i++){ col[i] = 0; } int c = 0; int in[N+1]; for(int i = 0; i <= N; i++) in[i] = 0; int pos[N+1]; bool is[2*N+1]; bool was[2*N+1]; for(int i = 0; i <= 2*N; i++) in[i] = was[i] = false; int sz = 0; for(int i = 1; i <= 2*N; i++){ int cur = Query(i); // printf("i = %d, cur = %d, c = %d\n",i,cur,c); if(cur != sz){ sz = cur; // printf("cur = %d\n",cur); pos[cur] = i; is[i] = 1; in[cur] = 1; col[i] = sz; was[i] = true; } else { sz = Query(i); } } // for(int i = 1; i <= 2*N; i++){ // printf("col[%d] = %d\n",i,col[i]); // } for(int bt = 0; (1 << bt) <= N; bt++){ for(int i = 1; i <= N; i++){ if(in[i] && (i >> bt & 1) == 0){ sz = Query(pos[i]); in[i] = false; } if(!in[i] && (i >> bt & 1) == 1){ sz = Query(pos[i]); in[i] = true; } // if(in[i]){ // printf("%d is in\n",pos[i]); // } } // printf("bt = %d\n",bt); for(int i = 1; i <= 2*N; i++){ if(was[i]) continue; int nw = Query(i); // printf("i = %d, sz = %d, nw = %d\n",i,sz,nw); if(nw == sz){ col[i] |= (1 << bt); } sz = Query(i); } } // for(int i = 1; i <= 2*N; i++){ // printf("col[%d] = %d\n",i,col[i]); // } std::vector<int> A[N+1]; for(int i = 1; i <= 2*N; i++){ A[col[i]].push_back(i); } for(int i = 1; i <= N; i++){ Answer(A[i][0],A[i][1]); } // printf("ok\n"); return; } /** 4 1 5 2 6 3 4 7 8 **/

Compilation message (stderr)

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:10:9: warning: unused variable 'c' [-Wunused-variable]
   10 |     int c = 0;
      |         ^
minerals.cpp:15:10: warning: variable 'is' set but not used [-Wunused-but-set-variable]
   15 |     bool is[2*N+1];
      |          ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...