Submission #440729

#TimeUsernameProblemLanguageResultExecution timeMemory
440729aryan12Combo (IOI18_combo)C++17
100 / 100
43 ms592 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string buttons[4] = {"A", "B", "X", "Y"}; int temp = press("AB"); //cout << "temp = " << temp << "\n"; string firstChar; if(temp != 0) { temp = press("A"); if(temp == 1) { firstChar = "A"; } else { firstChar = "B"; } } else { temp = press("X"); if(temp == 1) { firstChar = "X"; } else { firstChar = "Y"; } } string possible[3]; int pos = 0; for(int i = 0; i < 4; i++) { if(buttons[i] != firstChar) { possible[pos++] = buttons[i]; } } string res = firstChar; //cout << "firstChar = " << firstChar << "\n"; for(int i = 1; i < N; i++) { string check = ""; if(i != N - 1) { check = res + possible[0]; check += res + possible[1] + possible[0]; check += res + possible[1] + possible[1]; check += res + possible[1] + possible[2]; int ans = press(check); if(ans == i) { res += possible[2]; } else if(ans == i + 1) { res += possible[0]; } else { res += possible[1]; } } else { check = res + possible[0] + res + possible[1]; int ans = press(check); if(ans == N - 1) { res += possible[2]; } else { check = res + possible[0]; ans = press(check); if(ans == N - 1) { res += possible[1]; } else { res += possible[0]; } } } } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...