Submission #141427

#TimeUsernameProblemLanguageResultExecution timeMemory
141427MathStudent2002Combo (IOI18_combo)C++14
100 / 100
62 ms688 KiB
#include "combo.h" using namespace std; string guess_sequence(int N) { string p = "AB"; int coins = press(p); string cur = ""; char c[3]; if(coins == 0) { p = "X"; coins = press(p); if(coins == 0) {cur = "Y"; c[0] = 'A'; c[1] = 'B'; c[2] = 'X';} else {cur = "X"; c[0] = 'A'; c[1] = 'B'; c[2] = 'Y';} } else { p = "A"; coins = press(p); if(coins == 0) {cur = "B"; c[0] = 'A'; c[1] = 'X'; c[2] = 'Y';} else {cur = "A"; c[0] = 'B'; c[1] = 'X'; c[2] = 'Y';} } if(N == 1) return cur; string T; for(int i = 1; i <= N-2; i++) { T = (cur + c[0]) + (cur + c[1] + c[0]) + (cur + c[1] + c[1]) + (cur + c[1] + c[2]); coins = press(T); if(coins == i) {cur += c[2];} else if(coins == (i+1)) {cur += c[0];} else {cur += c[1];} } T = (cur + c[0]) + (cur + c[1]); coins = press(T); if(coins < N) {return (cur + c[2]);} T = cur + c[0]; coins = press(T); if(coins < N) {return (cur + c[1]);} return (cur + c[0]); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...