제출 #554181

#제출 시각아이디문제언어결과실행 시간메모리
554181d4xn콤보 (IOI18_combo)C++17
0 / 100
58 ms208 KiB
#include "combo.h" #pragma GCC optimize ("Ofast") #include <bits/stdc++.h> using namespace std; #define pb push_back string guess_sequence(int N) { string p; vector<char> f = {'A', 'B', 'X', 'Y'}; for (int j = 0; j < 4; j++) { int k = j + rand() % (4 - j); swap(f[j], f[k]); } int idx = 0; for (int i = 0; i < 3; i++) { p.pb(f[i]); if (i > 0) { for (int j = 1; j < N; j++) { char x = f[rand() % i]; p.pb(x); } } idx = press(p); if (idx) break; p.clear(); } bool iKnowCurr = idx > 0; if (!idx) { p.pb(f[3]); for (int i = 1; i < N; i++) { char x = f[rand() % 3]; p.pb(x); } } else { for (int i = 1; i < N; i++) { char x = f[rand() % 4]; while (x == p[0]) { x = f[rand() % 4]; } p[i] = x; } } vector<char> v; for (char i : {'A', 'B', 'X', 'Y'}) { if (p[0] == i) continue; v.pb(i); } for (int j = 0; j < 3; j++) { int k = j + rand() % (3 - j); swap(v[j], v[k]); } idx = max(idx, 1); while (idx < N) { if (iKnowCurr) { char x, y; x = y = 'a'; for (int i = 0; i < 3; i++) { if (p[idx] == v[i]) continue; if (x == 'a') x = v[i]; else y = v[i]; } p[idx] = x; int newIdx = press(p); if (newIdx > idx) { idx = newIdx; iKnowCurr = 1; continue; } p[idx] = y; iKnowCurr = 0; } else { char x, y, z; x = v[0]; y = v[1]; z = v[2]; p[idx] = x; int newIdx = press(p); if (newIdx > idx) { idx = newIdx; iKnowCurr = 1; continue; } p[idx] = y; newIdx = press(p); if (newIdx > idx) { idx = newIdx; iKnowCurr = 1; continue; } p[idx] = z; iKnowCurr = 0; } } return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...