제출 #617731

#제출 시각아이디문제언어결과실행 시간메모리
617731Minindu2006콤보 (IOI18_combo)C++14
100 / 100
36 ms636 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; std::string guess_sequence(int n) { int ops = 0; vector<string> cc{"A", "B", "X", "Y"}; string ans; int a = press("AB"); if(a > 0) { int b = press("A"); if(b == 1) ans += "A"; else ans += "B"; } else { int b = press("X"); if(b == 1) ans += "X"; else ans += "Y"; } vector<string> controls; for(int i=0;i<4;i++) { if(cc[i] != ans) controls.push_back(cc[i]); } string cur; if(n == 1) return ans; for(int i=1;i<n-1;i++) { // cout << ans << '\n'; cur = ans + controls[1] + ans + controls[0] + controls[0] + ans + controls[0] + controls[1] + ans + controls[0] + controls[2]; // cout << cur.size() << '\n'; ops++; int len = press(cur); if(len == i + 2) ans += controls[0]; else if(len == i + 1) ans += controls[1]; else ans += controls[2]; } // Since len(cur) > 4N if(press(ans + controls[0]) == n) ans += controls[0]; else if(press(ans + controls[1]) == n) ans += controls[1]; else ans += controls[2]; // cout << ops << '\n'; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...