제출 #75004

#제출 시각아이디문제언어결과실행 시간메모리
75004ainta콤보 (IOI18_combo)C++17
100 / 100
103 ms528 KiB
#include "combo.h" #include <algorithm> #include <string> using namespace std; char s[5] = "ABXY"; string p, res; void Put(int pv) { p += s[pv]; } void Clear() { p = ""; } std::string guess_sequence(int N) { int i, st = -1, j; Clear(); for (int i = 0; i < 2 * N; i++) Put(0); for (int i = 0; i < 2 * N; i++) Put(1); int t = press(p); if (t) { Clear(); for (i = 0; i < 4 * N; i++)Put(0); t = press(p); if (t)st = 0; else st = 1; } else { Clear(); for (i = 0; i < 4 * N; i++)Put(2); t = press(p); if (t)st = 2; else st = 3; } res = ""; res += s[st]; if (N == 1)return res; int p1 = (st + 1) % 4; int p2 = (st + 2) % 4; int p3 = (st + 3) % 4; for (i = 2; i < N; i++) { Clear(); p += res; Put(p1); for (j = 0; j < N - i; j++)Put(p1); p += res; Put(p1); for (j = 0; j < N - i; j++)Put(p2); p += res; Put(p1); for (j = 0; j < N - i; j++)Put(p3); p += res; Put(p2); for (j = 0; j < N - i; j++)Put(st); t = press(p); if (t == i - 1)res += s[p3]; else if (t == i)res += s[p2]; else res += s[p1]; } Clear(); p += res; Put(p1); for (i = 0; i < 3 * N; i++)Put(st); t = press(p); if (t == N)res += s[p1]; else { Clear(); p += res; Put(p2); for (i = 0; i < 3 * N; i++)Put(st); t = press(p); if (t == N)res += s[p2]; else res += s[p3]; } return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...