Submission #290575

#TimeUsernameProblemLanguageResultExecution timeMemory
290575gabrc52Combo (IOI18_combo)C++14
100 / 100
40 ms768 KiB
#include <iostream> #include <string> //#define DEBUG #ifdef DEBUG #define watch(x) cerr<<#x<<": "<<(x)<<endl #else #define watch(x) #endif #include "combo.h" using namespace std; char getFirst() { if (press("AB") >= 1) { return press("A")==1 ? 'A' : 'B'; } else { return press("X")==1 ? 'X' : 'Y'; } } string valid = "ABXY"; string newValid(string s, char first) { string r; for (char c : s) { if (c != first) { r.push_back(c); } } return r; } int sz(string s) { return s.size(); } string guess_sequence(int N) { string p,S; char first = getFirst(); S.push_back(first); watch(first); if (N > 1) { valid = newValid(valid,first); watch(valid); for (int i=2; i<N; i++) { int r = press(S+valid[0] + S+valid[1]+valid[0] + S+valid[1]+valid[1] + S+valid[1]+valid[2]); if (r == sz(S)) { S.push_back(valid[2]); } else if (r == sz(S) + 1) { S.push_back(valid[0]); } else { S.push_back(valid[1]); } watch(S); } if (press(S+valid[0] + S+valid[1]) == sz(S)) { S.push_back(valid[2]); } else if (press(S+valid[0]) == sz(S)) { S.push_back(valid[1]); } else { S.push_back(valid[0]); } watch(S); } return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...