Submission #997616

#TimeUsernameProblemLanguageResultExecution timeMemory
997616TimDeeMinerals (JOI19_minerals)C++17
90 / 100
30 ms3660 KiB
#include "minerals.h" #include <bits/stdc++.h> using namespace std; #define pb push_back void Solve(vector<int> l, vector<int> r, int in) { if(l.size()==1) { Answer(l[0],r[0]); return; } int pre; vector<int> L[2],R[2]; int sz=l.size()/2; if(l.size()==2) sz=1; for(int i=0;i<l.size();i++) L[i>=sz].pb(l[i]); for(int i:L[0]) pre=Query(i); for(int i:r) { if(L[0].size()==R[0].size()) R[1].pb(i); else if(L[1].size()==R[1].size()) R[0].pb(i); else { int now=Query(i); if(now==pre) { if(in) R[1].pb(i); else R[0].pb(i); } else { if(in) R[0].pb(i); else R[1].pb(i); } pre=now; } } Solve(L[0],R[0],in^1); Solve(L[1],R[1],in); } void Solve(int n) { srand(time(0)); vector<int> l,r; int pre=0; for(int i=1;i<=n*2;i++) { int now=Query(i); if(now!=pre) l.pb(i); else r.pb(i); pre=now; } Solve(l,r,1); }

Compilation message (stderr)

minerals.cpp: In function 'void Solve(std::vector<int>, std::vector<int>, int)':
minerals.cpp:16:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   16 |      for(int i=0;i<l.size();i++) L[i>=sz].pb(l[i]);
      |                  ~^~~~~~~~~
minerals.cpp:25:8: warning: 'pre' may be used uninitialized in this function [-Wmaybe-uninitialized]
   25 |        if(now==pre)
      |        ^~
#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...