Submission #998434

#TimeUsernameProblemLanguageResultExecution timeMemory
998434cnn008Combo (IOI18_combo)C++17
10 / 100
39 ms1104 KiB
#include "bits/stdc++.h" #include "combo.h" using namespace std; mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); int rand(int l, int r){ assert(l<=r); return uniform_int_distribution<int> (l,r)(rng); } string push_top(string &s, char c){ reverse(s.begin(),s.end()); s.push_back(c); reverse(s.begin(),s.end()); return s; } string pop_top(string &s){ reverse(s.begin(),s.end()); s.pop_back(); reverse(s.begin(),s.end()); return s; } string guess_sequence(int n) { char c[]={'A','B','X','Y'}; string s; while(1){ if((int)s.size()==n) break; bool f=0; vector <int> p(4); iota(p.begin(),p.end(),0); shuffle(p.begin(),p.end(),rng); for(int i=0; i<4; i++){ s.push_back(c[p[i]]); if(press(s)==(int)s.size()){ f=1; break; }else s.pop_back(); } if(!f) break; } while(1){ if((int)s.size()==n) break; bool f=0; for(int i=0; i<4; i++){ s=push_top(s,c[i]); if(press(s)==(int)s.size()){ f=1; break; }else s=pop_top(s); } if(!f) break; } return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...