제출 #270819

#제출 시각아이디문제언어결과실행 시간메모리
270819cjoa콤보 (IOI18_combo)C++11
5 / 100
1 ms200 KiB
#include "combo.h" #include <iostream> using namespace std; const string letters = "ABXY"; std::string guess_sequence(int N) { // cerr << "N:" << N << endl; string res; // determine first letter char matched_first_char; string cand = letters.substr(0, 2); int coins = press(cand); if (coins == 2) { res += cand; matched_first_char = cand[0]; } else { if (coins == 0) cand = letters.substr(2); coins = press(cand.substr(0, 1)); matched_first_char = cand[ coins == 0 ? 1 : 0 ]; res += matched_first_char; } cand = letters; int p = cand.find(matched_first_char); swap(cand[p], cand[3]); // cerr << "cand: " << cand << endl; // determine letters upto N-1 for (int n = res.size(); n < N-1; ++n) { string guess = res; guess += cand[1]; for (int k = 0; k < 3; ++k) { guess += res; guess += cand[2]; guess += cand[k]; } coins = press(guess); int k = coins - res.size(); // cerr << "n:" << n << " guess:" << guess << " coins:" << coins << endl; res += cand[k]; // cerr << "res:" << res << endl; } // determine last letter { string guess = res; guess += cand[0]; guess += cand[3]; guess += res; guess += cand[1]; coins = press(guess); if (coins == N) { guess = res + cand[0]; coins = press(guess); if (coins == N) res += cand[0]; else res += cand[1]; } else res += cand[2]; } // cerr << "res: " << res << endl; return res; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...