Submission #297199

#TimeUsernameProblemLanguageResultExecution timeMemory
297199Aldas25Combo (IOI18_combo)C++14
100 / 100
33 ms540 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define FOR(i, a, b) for (int i = (a); i <= (b); i++) #define REP(n) FOR(O, 1,(n)) #define f first #define s second #define pb push_back typedef vector<int> vi; typedef pair<int, int> pii; std::string guess_sequence(int n) { string buttons = "ABXY"; string ret = ""; string ask; ask = "AB"; int coins = press(ask); if (coins > 0) { ask = "A"; coins = press(ask); if (coins > 0) ret = "A"; else ret = "B"; } else { ask = "X"; coins = press(ask); if (coins > 0) ret = "X"; else ret = "Y"; } if (n == 1) return ret; string tmp = buttons; buttons = ""; for (char c : tmp) if (c != ret[0]) buttons += c; FOR(i, 1, n-2) { ask = ""; FOR(j, 0, 2) ask += ret + buttons[0] + buttons[j]; ask += ret + buttons[1]; coins = press(ask); if (coins == i) ret += buttons[2]; else if (coins == i+1) ret += buttons[1]; else ret += buttons[0]; } ask = ret + buttons[0] + ret + buttons[1]; coins = press(ask); // cout << " asked " << ask << " got: " << coins << endl; if (coins == n-1) ret += buttons[2]; else { ask = ret + buttons[0]; coins = press(ask); if (coins == n) ret += buttons[0]; else ret += buttons[1]; } //cout << "ret = " << ret << endl; return ret; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...