제출 #291645

#제출 시각아이디문제언어결과실행 시간메모리
291645SamAnd콤보 (IOI18_combo)C++17
100 / 100
93 ms640 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define m_p make_pair #define fi first #define se second #define all(x) (x).begin(),(x).end() #define sz(x) ((int)(x).size()) typedef long long ll; const int N = 2003; char u[4] = {'X', 'Y', 'A', 'B'}; std::string guess_sequence(int n) { string s; for (int i = 0; i < n * 2; ++i) s += u[0]; for (int i = 0; i < n * 2; ++i) s += u[1]; if (press(s)) { s.clear(); for (int i = 0; i < n * 4; ++i) s += u[1]; if (press(s)) swap(u[1], u[0]); } else { s.clear(); for (int i = 0; i < n * 4; ++i) s += u[2]; if (press(s)) swap(u[2], u[0]); else swap(u[3], u[0]); } string ans; ans += u[0]; while (sz(ans) != n) { if (n - sz(ans) >= 2) { string s; s += ans; s += u[2]; while (sz(s) % n != 0) s += u[0]; for (int i = 1; i <= 3; ++i) { s += ans; s += u[1]; s += u[i]; while (sz(s) % n != 0) s += u[0]; } int x = press(s); if (x == sz(ans)) ans += u[3]; else if (x == sz(ans) + 1) ans += u[2]; else ans += u[1]; } else { for (int i = 1; i < 3; ++i) { string s; for (int j = 0; j < 4; ++j) { s += ans; s += u[i]; } if (press(s) == n) { ans += u[i]; break; } } if (sz(ans) != n) ans += u[3]; } } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...