Submission #158866

#TimeUsernameProblemLanguageResultExecution timeMemory
158866usernameMinerals (JOI19_minerals)C++14
100 / 100
56 ms2548 KiB
#include "minerals.h" #pragma GCC optimize("O3") #include<bits/stdc++.h> using namespace std; #define REP(i,j,k) for(int i=(j);i<(k);++i) #define pb push_back // #define __debug #ifdef __debug #define pr(...) cerr<<__VA_ARGS__ #define ar(a,s,t) {rep(zy,s,t)pr(a[zy]<<' ');pr(endl);} #else #define pr(...) (void)0 #define ar(...) (void)0 #endif // int ls=0,ll=0; vector<int>v[2]; int qr(int x){ int t=Query(x+1); swap(t,ls); return ls==t; } void sol(int l,int r,vector<int>&vec){ if(l+1==r)Answer(v[0][l]+1,vec[0]+1); else{ int mid; vector<int>vv[2]; if(l>ll){ mid=l+round(0.37*(r-l)); REP(i,l,mid)qr(v[0][i]); }else{ mid=l+round(0.63*(r-l)); REP(i,mid,r)qr(v[0][i]); } ll=l; REP(i,0,vec.size()){ int t=vec[i]; if(vv[1].size()==mid-l)vv[0].pb(t); else if(vv[0].size()==r-mid)vv[1].pb(t); else vv[qr(t)].pb(t); } sol(l,mid,vv[1]); sol(mid,r,vv[0]); } vector<int>().swap(vec); } void Solve(int n){ REP(i,0,2*n)v[qr(i)].pb(i); random_shuffle(v[1].begin(),v[1].end()); sol(0,n,v[1]); }

Compilation message (stderr)

minerals.cpp: In function 'void sol(int, int, std::vector<int>&)':
minerals.cpp:5:35: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,j,k) for(int i=(j);i<(k);++i)
                                   ^
minerals.cpp:38:3: note: in expansion of macro 'REP'
   REP(i,0,vec.size()){
   ^~~
minerals.cpp:40:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    if(vv[1].size()==mid-l)vv[0].pb(t);
       ~~~~~~~~~~~~^~~~~~~
minerals.cpp:41:24: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
    else if(vv[0].size()==r-mid)vv[1].pb(t);
            ~~~~~~~~~~~~^~~~~~~
#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...