Submission #126367

#TimeUsernameProblemLanguageResultExecution timeMemory
126367TadijaSebezMinerals (JOI19_minerals)C++14
100 / 100
75 ms4280 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()/3; 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:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<l.size();i++) L[i>=sz].pb(l[i]);
              ~^~~~~~~~~
minerals.cpp:25:4: warning: 'pre' may be used uninitialized in this function [-Wmaybe-uninitialized]
    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...