제출 #99148

#제출 시각아이디문제언어결과실행 시간메모리
99148JustasLe콤보 (IOI18_combo)C++17
100 / 100
58 ms572 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { set<char> X = {'A', 'B', 'X', 'Y'}; string s = ""; if (N < 2) { if (press("A")) { return "A"; } if (press("B")) { return "B"; } if (press("X")) { return "X"; } return "Y"; } else { int t = press("AB"); if (t > 0) { if (press("A")) { s += "A"; } else { s += "B"; } } else { if (press("X")) { s += "X"; } else { s += "Y"; } } } X.erase(s[0]); int prev = 1; while (true) { int sz = (int) s.size(), c = 0; if (sz == N - 1) { for (auto it = X.begin(); it != X.end(); it++, c++) { string poss = s + *it; int x = press(poss); if (x > prev) { return poss; } if (c == 1) { return s + *(++it); } } } // vector<string> extraX = {"XX", "XY", "XB"}; // vector<string> extraA = {"AX", "AY", "AB"}; // vector<string> extraB = {"BA", "BX", "BY"}; // vector<string> extraY = {"YX", "YA", "YB"}; if (s[0] == 'A') { int x = press(s + "Y" + s + "XX" + s + "XY" + s + "XB"); if (x == prev) { s += 'B'; prev++; continue; } else { if (x == prev + 1) { s += "Y"; prev++; continue; } else { s += "X"; prev++; continue; } } } if (s[0] == 'B') { int x = press(s + "Y" + s + "XX" + s + "XY" + s + "XA"); if (x == prev) { s += 'A'; prev++; continue; } else { if (x == prev + 1) { s += "Y"; prev++; continue; } else { s += "X"; prev++; continue; } } } if (s[0] == 'X') { int x = press(s + "Y" + s + "BB" + s + "BY" + s + "BA"); if (x == prev) { s += 'A'; prev++; continue; } else { if (x == prev + 1) { s += "Y"; prev++; continue; } else { s += "B"; prev++; continue; } } } if (s[0] == 'Y') { int x = press(s + "B" + s + "XX" + s + "XB" + s + "XA"); if (x == prev) { s += 'A'; prev++; continue; } else { if (x == prev + 1) { s += "B"; prev++; continue; } else { s += "X"; prev++; continue; } } } } return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...