Submission #251910

#TimeUsernameProblemLanguageResultExecution timeMemory
251910paradoxCombo (IOI18_combo)C++17
100 / 100
41 ms724 KiB
#include "combo.h" #include <iostream> #include <fstream> #include <vector> #include <set> #include <map> #include <cstring> #include <string> #include <cmath> #include <cassert> #include <ctime> #include <algorithm> #include <sstream> #include <list> #include <queue> #include <deque> #include <stack> #include <cstdlib> #include <cstdio> #include <iterator> #include <functional> #include <unordered_set> #include <unordered_map> using namespace std; #define fi first #define se second #define mp make_pair #define pb push_back #define sz(x) (int)x.size() #define all(x) x.begin(), x.end() #define pii pair<int, int> #define vi vector<int> #define fast_io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0) char ch[] = {'A', 'B', 'X', 'Y'}; char findNextCharacter(string currentString) { int f = 0, s = 1; string query = currentString + ch[f] + currentString + ch[s]; int res = press(query); if (res == sz(currentString)) f = 2, s = 3; query = currentString + ch[f]; res = press(query); return (res != sz(currentString) ? ch[f] : ch[s]); } string guess_sequence(int N) { char first = findNextCharacter(""); string ans = ""; ans += first; string buttons = ""; for (int i = 0; i < 4; ++i) if (first != ch[i]) buttons += ch[i]; for (int i = 2; i < N; ++i) { string query = ""; query = ans + buttons[1]; for (int j = 0; j < 3; ++j) query += ans + buttons[2] + buttons[j]; int res = press(query); if (res == i - 1) ans += buttons[0]; else if (res == i) ans += buttons[1]; else ans += buttons[2]; } if (N > 1) { char last = findNextCharacter(ans); ans += last; } return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...