Submission #345960

#TimeUsernameProblemLanguageResultExecution timeMemory
345960AlmaCombo (IOI18_combo)C++14
100 / 100
44 ms696 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 } // if N = 1... if (N == 1) {return S;} // guess from 2nd letter to N-1 (num of calls to "press" = N-2) while ((int)S.length() < N-1) { int i = (int)S.length(); p = S + v[0]+v[0] + S + v[0]+v[1] + S + v[0]+v[2] + S + v[1]; // f.e. 1st = A p = SBB SBX SBY SX coins = press(p); if (coins == i+2) {S += v[0];} // next letter = B v[0] else if (coins == i+1) {S += v[1];} // next letter = X v[1] else {S += v[2];} // next letter = Y v[2] i++; } // 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...