제출 #345875

#제출 시각아이디문제언어결과실행 시간메모리
345875Alma콤보 (IOI18_combo)C++14
5 / 100
1 ms248 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<char> 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) for (int i = 1; i < N-1; i++) { p = S + v[0]+v[0] + S + v[0]+v[1] + S + v[0]+v[2] + S + v[1]; // f.e. 1st = A p = S BB S BX S BY S X 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] } // 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...