제출 #750179

#제출 시각아이디문제언어결과실행 시간메모리
750179tlnk07콤보 (IOI18_combo)C++17
100 / 100
34 ms576 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string s; string c[10]; int hm = press("AB"); if(hm == 0) { if(press("X") == 0) { s += 'Y'; c[1] = 'A'; c[2] = 'B'; c[3] = 'X'; } else { s += 'X'; c[1] = 'A'; c[2] = 'B'; c[3] = 'Y'; } } else if(hm == 1) { if(press("A") == 0) { s += 'B'; c[1] = 'A'; c[2] = 'Y'; c[3] = 'X'; } else { s += 'A'; c[1] = 'X'; c[2] = 'B'; c[3] = 'Y'; } } else { s += "AB"; c[1] = 'X'; c[2] = 'B'; c[3] = 'Y'; } int sz = s.size(); while(sz < N - 1) { string temp = s + c[1] + c[1] + s + c[1] + c[2] + s + c[2] + c[1]; int inp = press(temp); if(inp == sz) { s += c[3]; } else if(inp == sz + 1) { string temp1 = s + c[2] + c[2]; int inp1 = press(temp1); if(inp1 == sz + 2) { s = temp1; } else if(inp1 == sz + 1) { s += c[2] + c[3]; } else { s += c[1] + c[3]; } } else { string temp1 = s + c[1] + c[1]; int inp1 = press(temp1); if(inp1 == sz + 2) { s = temp1; } else if(inp1 == sz + 1) { s += c[1] + c[2]; } else { s += c[2] + c[1]; } } sz = s.size(); } if(sz == N) { return s; } else { string temp = s + c[1]; if(press(temp) == N) { return temp; } else { temp = s + c[2]; if(press(temp) == N) { return temp; } else { return s + c[3]; } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...