Submission #916937

#TimeUsernameProblemLanguageResultExecution timeMemory
916937manishjha91Combo (IOI18_combo)C++17
100 / 100
17 ms2024 KiB
#include "combo.h" #include <bits/stdc++.h> std::string guess_sequence(int N){ using namespace std; string v = "ABXY"; string s = ""; int f = -1; string curr = ""+string(1,v[0]) + string(1,v[1]); if(press(curr)) { if(press(string(1,v[0]))) { f = 0; } else f = 1; } else { if(press(string(1,v[2]))) { f = 2; } else f = 3; } s.push_back(v[f]); swap(v[f],v.back()); v.pop_back(); if(N==1) return s; for(int i=0; i<N-2; i++) { int n = s.size(); string s1 = s; string s2 = s; string s3 = s; string s4 = s; s1 = s1 + v[0]+v[0]; s2 = s2 + v[0]+v[1]; s3 = s3 + v[0]+v[2]; s4 = s4 + v[1]; string curr = s1 + s2 + s3 + s4; int cnt = press(curr); if(cnt==n+2) { s.push_back(v[0]); } else if(cnt==n+1) s.push_back(v[1]); else s.push_back(v[2]); } s.push_back(v[0]); if(press(s)==N) { return s; } s.pop_back(); s.push_back(v[1]); if(press(s)==N) { return s; } s.pop_back(); s.push_back(v[2]); return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...