Submission #310642

#TimeUsernameProblemLanguageResultExecution timeMemory
310642LucaDantasCombo (IOI18_combo)C++17
100 / 100
38 ms600 KiB
/*#include<bits/stdc++.h> using namespace std; #include "combo.h" #define pb push_back #define sz(a) (int)((a).size()) string guess_sequence(int n) { string p = ""; vector<char> dif; if(press("AB")) { if(press("A")) p = "A"; else p = "B"; } else if(press("X")) p = "X"; else p = "Y"; for(char c : {'A','B','X','Y'}) if(c != p[0]) dif.pb(c); for(int i = 1; i < n-1; i++) { string q = p; q.pb(dif[0]); for(int j = 0; j < 3; j++) { q += p; q.pb(dif[1]); q.pb(dif[j]); } int ans = press(q); if(ans == sz(p)) p.pb(dif[2]); else if(ans == sz(p)+1) p.pb(dif[0]); else p.pb(dif[1]); } bool ok = 0; for(int j = 0; j < 2; j++) { p.pb(dif[j]); if(press(p) == n) {ok = 1; break;}; p.pop_back(); } if(!ok) p.pb(dif[2]); return p; } */ #include<bits/stdc++.h> using namespace std; #include "combo.h" #define pb push_back #define sz(a) (int)((a).size()) string guess_sequence(int N) { string p = ""; vector<char> dif; if(press("AB")) { if(press("A")) p = "A"; else p = "B"; } else if(press("X")) p = "X"; else p = "Y"; for(char c : {'A','B','X','Y'}) if(c != p[0]) dif.pb(c); /*for(int i = 1; i < n; i++) { for(char c : dif) { p.pb(c); if(press(p) == sz(p)) break; p.pop_back(); } }*/ int last = 1; for(int i = 1; i < N-1; i++) { string q = ""; q += p; q.pb(dif[1]); for(int j = 0; j < 3; j++) { q += p; q.pb(dif[0]); q.pb(dif[j]); } int ans = press(q); if(ans == sz(p)) p.pb(dif[2]); else if(ans == sz(p)+1) p.pb(dif[1]); else p.pb(dif[0]); assert(sz(p) - last == 1); last = sz(p); } if(sz(p) == N) return p; assert(sz(p) < N); // cout << p << '\n'; for(int j = 0; j < 2; j++) if(press(p + dif[j]) == N) return p + dif[j]; return p + dif[2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...