제출 #705622

#제출 시각아이디문제언어결과실행 시간메모리
705622garyye콤보 (IOI18_combo)C++14
5 / 100
1 ms208 KiB
#include "combo.h" #include <iostream> #include <vector> #include <algorithm> using namespace std; int mpress(string s) { int g = press(s); // cout << "Press " << s << " = " << g << endl; return g; } std::string guess_sequence(int N) { vector<char> c = {'A', 'B', 'X', 'Y'}; string f = ""; if(press("XY") > 0) { f = mpress("X") > 0 ? "X" : "Y"; } else { f = mpress("A") > 0 ? "A" : "B"; } c.erase(find(c.begin(), c.end(), f[0])); // A. -> 1 // BA. -> 2 // BB. -> 2 // BC. -> 2 // B. -> 1 // CA -> 2 // CB -> 2 for(int i = 1; i < N - 1; ++i) { string s = ""; s += f + c[0]; s += f + c[1] + c[0]; s += f + c[1] + c[1]; s += f + c[1] + c[2]; int g = mpress(s) - i; if(g == 0) f += c[2]; if(g == 1) f += c[0]; if(g == 2) f += c[1]; // cout << "f = " << f << endl; } // 2 + (N - 2) calls done if(mpress(f + c[0]) == N) return f + c[0]; if(mpress(f + c[1]) == N) return f + c[1]; return f + c[2]; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...