Submission #1072718

#TimeUsernameProblemLanguageResultExecution timeMemory
1072718boyliguanhanMinerals (JOI19_minerals)C++17
90 / 100
351 ms7920 KiB
#include "minerals.h" #include<bits/stdc++.h> using namespace std; set<int>st; int query(int k){ if(st.count(k)) st.erase(k); else st.insert(k); return Query(k); } mt19937 rng(random_device{}()); void solve(vector<int>A,vector<int>B,int dep){ if(A.size()==1) return Answer(A[0],B[0]); vector<int>A1,A2; vector<int>B1,B2; for(auto i:A) A1.push_back(i),swap(A1,A2); int prv=0; for(auto i:A1) prv=query(i); shuffle(B.begin(),B.end(),rng); for(auto i:B) { if(A1.size()==B1.size()){ B2.push_back(i); continue; } else if(A2.size()==B2.size()){ B1.push_back(i); continue; } int x=query(i); if(st.count(A1[0])^(x==prv)) B2.push_back(i); else B1.push_back(i); prv=x; } solve(A1,B1,dep^1); solve(A2,B2,dep^1); } void Solve(int N) { vector<int>A,B; int prv=0; vector<int>VV(2*N); iota(VV.begin(),VV.end(),1); shuffle(VV.begin(),VV.end(),rng); for(auto i:VV) { if(A.size()==N){ B.push_back(i); continue; } else if(B.size()==N){ A.push_back(i); continue; } if(query(i)!=prv) A.push_back(i),prv++; else B.push_back(i); } solve(A,B,0); }

Compilation message (stderr)

minerals.cpp: In function 'void Solve(int)':
minerals.cpp:46:16: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   46 |     if(A.size()==N){
      |        ~~~~~~~~^~~
minerals.cpp:49:23: warning: comparison of integer expressions of different signedness: 'std::vector<int>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   49 |     } else if(B.size()==N){
      |               ~~~~~~~~^~~
#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...