Submission #489804

#TimeUsernameProblemLanguageResultExecution timeMemory
489804DAleksaCombo (IOI18_combo)C++17
100 / 100
30 ms592 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { char f; string s; s = "AB"; int Q = 0; int q = press(s); Q++; if(q == 2) f = 'A'; else if(q == 1) { s = "A"; Q++; if(press(s) == 1) f = 'A'; else f = 'B'; } else { s = "X"; Q++; if(press(s) == 1) f = 'X'; else f = 'Y'; } char c[4] = {'A', 'B', 'X', 'Y'}; if(f == 'B') swap(c[1], c[0]); else if(f == 'X') swap(c[2], c[0]); else if(f == 'Y') swap(c[3], c[0]); s = ""; for(int i = 0; i < 4*n; i++) s += c[0]; for(int i = 1; i < n-1; i++) { s[i] = s[i+n] = s[i+2*n] = c[1]; s[i+1] = c[1]; s[i+1+n] = c[2]; s[i+1+2*n] = c[3]; s[i+3*n] = c[2]; Q++; int x = press(s); if(x == i+2) s[i] = s[i+n] = s[i+2*n] = s[i+3*n] = c[1]; else if(x == i+1) s[i] = s[i+n] = s[i+2*n] = s[i+3*n] = c[2]; else s[i] = s[i+n] = s[i+2*n] = s[i+3*n] = c[3]; } if(n > 1) { s[n-1] = 'A'; s[2*n-1] = 'B'; s[3*n-1] = 'A'; s[4*n-1] = 'B'; Q++; q = press(s); if(q == n) { s[2*n-1] = s[4*n-1] = 'A'; Q++; if(press(s) != n) s[n-1] = 'B'; } else { s[n-1] = s[2*n-1] = s[3*n-1] = s[4*n-1] = 'X'; Q++; if(press(s) != n) s[n-1] = 'Y'; } } string t = ""; for(int i = 0; i < n; i++) t += s[i]; assert(Q <= n+2); return t; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...