Submission #1077953

#TimeUsernameProblemLanguageResultExecution timeMemory
1077953azberjibiouMinerals (JOI19_minerals)C++17
100 / 100
49 ms3756 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; int ret; void solv(vector <int> v1, vector <int> v2, int in1, int in2){ int sz=v2.size(); if(sz==1){ Answer(v1[0], v2[0]); return; } std::random_shuffle(v1.begin(), v1.end()); vector <int> v11, v12, v21, v22; int mid=(int)(sz*0.45+0.5); for(int i=0;i<mid;i++) ret=Query(v1[i]), v11.push_back(v1[i]); for(int i=mid;i<sz;i++) v12.push_back(v1[i]); int cur; for(int i=0;i<sz;i++){ if(v11.size()==v21.size() || v12.size()==v22.size()){ cur=i; break; } int nr=Query(v2[i]); if(nr==ret){ if(in1==1) v22.push_back(v2[i]); else v21.push_back(v2[i]); } else{ if(in1==1) v21.push_back(v2[i]); else v22.push_back(v2[i]); } ret=nr; } for(int i=cur;i<sz;i++){ if(v11.size()!=v21.size()) v21.push_back(v2[i]); else v22.push_back(v2[i]); } solv(v11, v21, 1-in1, 1-in2); solv(v12, v22, in1, 1-in2); } void Solve(int N) { if(N==1){ Answer(1, 2); return; } ret=0; vector <int> v1, v2; for(int i=1;i<=2*N;i++){ int nr=Query(i); if(nr==ret) v2.push_back(i); else v1.push_back(i); ret=nr; } solv(v1, v2, 1, 1); }

Compilation message (stderr)

minerals.cpp: In function 'void solv(std::vector<int>, std::vector<int>, int, int)':
minerals.cpp:17:9: warning: 'cur' may be used uninitialized in this function [-Wmaybe-uninitialized]
   17 |     int cur;
      |         ^~~
#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...