제출 #870033

#제출 시각아이디문제언어결과실행 시간메모리
870033attky콤보 (IOI18_combo)C++17
100 / 100
11 ms2068 KiB
#include <iostream> using namespace std; int press(string p); string guess_sequence(int n) { int nb; string combo = "", entree = ""; char debut; nb = press("AB"); if(nb >= 1) { nb = press("A"); if(nb == 1) combo = "A"; else combo = "B"; } else { nb = press("X"); if(nb == 1) combo = "X"; else combo = "Y"; } debut = combo[0]; for(int loop = 1; loop < n-1; ++loop) { entree = ""; if(debut == 'A') { entree += combo; entree += "BB"; entree += combo; entree += "BX"; entree += combo; entree += "BY"; entree += combo; entree += "X"; nb = press(entree); if(nb - combo.size() == 0) combo += 'Y'; else if(nb - combo.size() == 1) combo += 'X'; else combo += 'B'; } else if(debut == 'B') { entree += combo; entree += "AA"; entree += combo; entree += "AX"; entree += combo; entree += "AY"; entree += combo; entree += "X"; nb = press(entree); if(nb - combo.size() == 0) combo += 'Y'; else if(nb - combo.size() == 1) combo += 'X'; else combo += 'A'; } else if(debut == 'X') { entree += combo; entree += "AA"; entree += combo; entree += "AB"; entree += combo; entree += "AY"; entree += combo; entree += "B"; nb = press(entree); if(nb - combo.size() == 0) combo += 'Y'; else if(nb - combo.size() == 1) combo += 'B'; else combo += 'A'; } else if(debut == 'Y') { entree += combo; entree += "BA"; entree += combo; entree += "BB"; entree += combo; entree += "BX"; entree += combo; entree += "A"; nb = press(entree); if(nb - combo.size() == 0) combo += 'X'; else if(nb - combo.size() == 1) combo += 'A'; else combo += 'B'; } } entree = ""; entree = combo; entree += 'A'; entree += combo; entree += 'B'; nb = press(entree); if(n > 1) { if(nb == n) { entree = ""; entree = combo; entree += 'A'; nb = press(entree); if(nb == n) combo += 'A'; else combo += 'B'; } else { entree = ""; entree = combo; entree += 'X'; nb = press(entree); if(nb == n) combo += 'X'; else combo += 'Y'; } } return combo; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...