제출 #541489

#제출 시각아이디문제언어결과실행 시간메모리
541489Mdominykas콤보 (IOI18_combo)C++14
100 / 100
36 ms636 KiB
#include <vector> #include <iostream> #include "combo.h" using namespace std; std::string guess_sequence(int N) { // cout << "N = " << N << endl; vector<char> letters = {'A', 'B', 'X', 'Y'}; char init; if(press("AB") >= 1) { if(press("A") >= 1) init = 'A'; else init = 'B'; } else { if(press("X") >= 1) init = 'X'; else init = 'Y'; } for(int i = 0; i < (int)letters.size(); i++) { if(letters[i] == init) swap(letters[i], letters.back()); } letters.pop_back(); // vector<char> p; // p.pus // cout << "init = " << init << endl; std::string p = ""; p += init; if(N == 1) return p; // cout << "init p = " << p << endl; for(int i = 1; i < N - 1; i++) { string S = p + letters[0] + p + letters[1] + letters[0] + p + letters[1] + letters[1] + p + letters[1] + letters[2]; int coins = press(S); if(coins == (int) p.size()) p += letters[2]; else if (coins == (int) p.size() + 1) p += letters[0]; else p += letters[1]; } // cout << "near final: " << p << endl; if(press(p + letters[0]) == N) p += letters[0]; else if(press(p + letters[1]) == N) p += letters[1]; else p += letters[2]; return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...