제출 #1021378

#제출 시각아이디문제언어결과실행 시간메모리
1021378Aisha콤보 (IOI18_combo)C++17
100 / 100
31 ms2196 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { string s = ""; string p = "AB"; int coins = press(p); if (coins == 2) s = p; else if (coins == 1) { p = "A"; coins = press(p); if (coins == 1) s = "A"; else s = "B"; } else { p = "X"; coins = press(p); if (coins == 1) s = "X"; else s = "Y"; } string A = "ABXY"; string a = ""; for (char c : A) { if (s[0] != c) a = a + c; } coins = 1; int sz = s.size(); while (sz < N - 1) { p = ""; for (int i = 0; i < 4; i++) { p = p + s; if (i < 3) { p = p + a[0]; p = p + a[i]; } else p = p + a[1]; } int k = press(p) - s.size(); if (k == 2) { s += a[0]; } else if (k == 1) { s += a[1]; } else { s += a[2]; } sz = s.size(); } if (sz == N) { return s; } p = s; p += a[0]; p += s; p += a[1]; int k = press(p) - s.size(); if (k == 1) { p = s; p += a[0]; if (press(p) - s.size() == 1) { s += a[0]; } else s += a[1]; } else s += a[2]; return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...