Submission #815774

#TimeUsernameProblemLanguageResultExecution timeMemory
815774JakobZorzMinerals (JOI19_minerals)C++14
40 / 100
29 ms3504 KiB
#include"minerals.h" #include<iostream> #include<vector> using namespace std; int inside; int last; int flag[100000]; int query(int a){ flag[a]++; flag[a]%=2; if(flag[a]) inside++; else inside--; last=Query(a); return last; } void solve(vector<int>up,vector<int>dn,bool inv){ //cout<<up.size()<<" "<<dn.size()<<"\n"; if(up.size()==1){ if(flag[up[0]]) query(up[0]); Answer(up[0],dn[0]); return; } vector<int>up1,up2; vector<int>dn1,dn2; for(int i=0;i<(int)up.size()/2;i++) up1.push_back(up[i]); for(int i=(int)up.size()/2;i<(int)up.size();i++) up2.push_back(up[i]); if(inv) for(int i:up2) query(i); else for(int i:up1) query(i); for(int i:dn){ int prev=last; query(i); bool to_first=prev==last; if(to_first) dn1.push_back(i); else dn2.push_back(i); } solve(up1,dn1,true); solve(up2,dn2,false); } void Solve(int N){ vector<int>up,dn; int prev=0; for(int i=1;i<=2*N;i++){ query(i); if(last!=prev) up.push_back(i); else dn.push_back(i); prev=last; } for(int i=1;i<=2*N;i++) query(i); solve(up,dn,false); }
#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...