제출 #1142664

#제출 시각아이디문제언어결과실행 시간메모리
1142664programming23Combo (IOI18_combo)C++20
100 / 100
7 ms524 KiB
#include "combo.h" #include "bits/stdc++.h" using namespace std; string guess_sequence(int N) { string s = ""; vector<char> posible; int ans = press("AB"); if(ans == 0){ ans = press("X"); if(ans == 0){ s = "Y"; posible = {'A', 'B', 'X'}; }else{ s = 'X'; posible = {'A', 'B', 'Y'}; } }else{ ans = press("A"); if(ans == 0) {s = "B";posible = {'A', 'X', 'Y'};} else{s = 'A';posible = {'X', 'B', 'Y'};} } char first = s[0]; int ln = 1; if (N == 1){ return s; } while (ln != N-1){ string query= s+posible[0]; for(int i=0; i < 3; i++){ query += s+posible[1]+posible[i]; } ans = press(query); if(ans == ln+1){ s+= posible[0]; }else if(ans == ln+2){ s+= posible[1]; }else{ s+= posible[2]; } ln+=1; } ans = press(s+posible[0]+s+posible[1]); if(ans == ln){ return s+posible[2]; }else{ ans = press(s+posible[0]); if(ans == ln) return s+posible[1]; else{return s+posible[0];} } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...