Submission #778703

#TimeUsernameProblemLanguageResultExecution timeMemory
778703Minindu206Combo (IOI18_combo)C++14
100 / 100
27 ms672 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int n) { vector<string> cont; string seq; int cc = press("AB"); if(cc) { if(press("A")) seq = "A"; else seq = "B"; } else { if(press("X")) seq = "X"; else seq = "Y"; } for (auto c : {"A", "B", "X", "Y"}) if (c != seq) cont.push_back(c); if(n == 1) return seq; for (int i = 1; i < n - 1; i++) { string cpress = seq + cont[0] + seq + cont[1] + cont[0] + seq + cont[1] + cont[1] + seq + cont[1] + cont[2]; int cur = press(cpress) - i; if(cur == 1) seq += cont[0]; else if(cur == 2) seq += cont[1]; else seq += cont[2]; } for(auto c:cont) { if(c == cont[2]) { seq += c; break; } if(press(seq + c) == n) { seq += c; break; } } return seq; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...