제출 #211044

#제출 시각아이디문제언어결과실행 시간메모리
211044Seanliu콤보 (IOI18_combo)C++14
100 / 100
99 ms776 KiB
#include <string> #include "combo.h" #include <vector> #include <deque> using namespace std; const int maxN = 2e3 + 10; int ans[maxN]; string c; vector<int> tmp; string getStr(){ string s = ""; for(int x : tmp) s += c[x]; return s; } std::string guess_sequence(int N) { int r; c = ""; string current = "AB"; r = press(current); if(r){ current = "A"; r = press(current); if(r) c = "ABXY"; else c = "BAXY"; } else { current = "Y"; r = press(current); if(r) c = "YABX"; else c = "XABY"; } for(int i = 1; i < N - 1; i++){ tmp.clear(); for(int j = 0; j < i; j++) tmp.push_back(ans[j]); tmp.push_back(1); for(int j = 0; j < i; j++) tmp.push_back(ans[j]); tmp.push_back(2); tmp.push_back(1); for(int j = 0; j < i; j++) tmp.push_back(ans[j]); tmp.push_back(2); tmp.push_back(2); for(int j = 0; j < i; j++) tmp.push_back(ans[j]); tmp.push_back(2); tmp.push_back(3); r = press(getStr()); if(r == i) ans[i] = 3; else if(r == i + 1) ans[i] = 1; else ans[i] = 2; } if(N == 1){ tmp.push_back(0); return getStr(); } tmp.clear(); for(int j = 0; j < N - 1; j++) tmp.push_back(ans[j]); tmp.push_back(1); for(int j = 0; j < N - 1; j++) tmp.push_back(ans[j]); tmp.push_back(2); if(press(getStr()) == N){ tmp.clear(); for(int j = 0; j < N - 1; j++) tmp.push_back(ans[j]); tmp.push_back(1); if(press(getStr()) == N) return getStr(); tmp[N - 1] = 2; return getStr(); } tmp.clear(); for(int j = 0; j < N - 1; j++) tmp.push_back(ans[j]); tmp.push_back(3); return getStr(); }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...