Submission #779774

#TimeUsernameProblemLanguageResultExecution timeMemory
779774mindiyakCombo (IOI18_combo)C++14
100 / 100
28 ms748 KiB
#include "combo.h" #include <string> #include <iostream> #include <vector> using namespace std; int vpress(string a){ // cout << "try - " << a; int val = press(a); // cout << " - " << val << endl; return val; } string repeat(int a,string str){ for(int i=0;i<a-1;i++){ str += str; } return str; } string guess_sequence(int N) { string ans = ""; vector<char> possible = {'A','B','X','Y'};; if(vpress("AB") >= 1){ if(vpress("A") == 1){ ans = "A"; possible.erase(possible.begin()+0); }else{ ans = "B"; possible.erase(possible.begin()+1); } }else{ if(vpress("X") == 1){ ans = "X"; possible.erase(possible.begin()+2); }else{ ans = "Y"; possible.erase(possible.begin()+3); } } if(N == 1) return ans; int counter = 1; for(int i =1;i<N-1;i++){ string temp = ans+string(1,possible[0]); temp += ans+string(1,possible[1])+string(1,possible[0]); temp += ans+string(1,possible[1])+string(1,possible[1]); temp += ans+string(1,possible[1])+string(1,possible[2]); // temp += repeat(2,(ans+string(1,possible[1]))); int val = vpress(temp); if(val == counter+1){ ans = ans + string(1,possible[0]); }else if(val == counter+2){ ans = ans + string(1,possible[1]); }else { ans = ans + string(1,possible[2]); } counter += 1; // cout << "ans -> " << ans << " " << counter << " " << N << endl; } if(vpress(ans+string(1,possible[0])) == N){ ans = ans + string(1,possible[0]); }else{ if(vpress(ans+string(1,possible[1])) == N){ ans = ans + string(1,possible[1]); }else{ ans = ans + string(1,possible[2]); } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...