Submission #345947

#TimeUsernameProblemLanguageResultExecution timeMemory
345947BlancaHMCombo (IOI18_combo)C++14
100 / 100
49 ms672 KiB
#include <iostream> #include <vector> #include <string> #include <combo.h> using namespace std; string guess_sequence(int N) { // 100 points: N + 2 calls to "press" string p = ""; string S = ""; vector<string> v = {}; int coins = 0; // guess 1st letter of S (num of calls to "press" = 2) p = "AB"; coins = press(p); if (coins >= 1) { p = "A"; coins = press(p); if (coins == 1) {S = "A"; v = {"B", "X", "Y"};} // 1st letter = A else {S = "B"; v = {"A", "X", "Y"};} // 1st letter = B } else { p = "X"; coins = press(p); if (coins == 1) {S = "X"; v = {"A", "B", "Y"};} // 1st letter = X else {S = "Y"; v = {"A", "B", "X"};} // 1st letter = Y } // guess from 2nd letter to N-1 (num of calls to "press" = N-2) while (3*((int) S.length() + 2) + (int) S.length() + 1 <= 4*N) { p = S + v[0]+v[0] + S + v[0]+v[1] + S + v[0]+v[2] + S + v[1]; coins = press(p); if (coins == (int) S.length() +2) {S += v[0];} // next letter = B v[0] else if (coins == (int) S.length() +1) {S += v[1];} // next letter = X v[1] else {S += v[2];} // next letter = Y v[2] } if ((int) S.length() < N) { // guess last letter of S (num of calls to "press" = 2) p = S + v[0]; coins = press(p); if (coins == N) {S += v[0];} else { p = S + v[1]; coins = press(p); if (coins == N) {S += v[1];} else {S += v[2];} } } // total of calls to "press" = 2 + N-2 + 2 = (N + 2) return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...