제출 #962214

#제출 시각아이디문제언어결과실행 시간메모리
962214anango콤보 (IOI18_combo)C++17
100 / 100
18 ms2104 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string p=""; int n=press("AB"); char first; if (n>=1) { int m=press("A"); if (m==1) { first='A'; } else { first='B'; } } else { int m=press("X"); if (m==1) { first='X'; } else { first='Y'; } } if (N==1) { string st; st.push_back(first); return st; } string cur(1,first); set<string> others={"A", "B","X","Y"}; vector<string> v; others.erase(cur); for (auto i:others) { v.push_back(i); } for (int i=1; i<N-1; i++) { string guesseq=""; for (int j=0; j<3; j++) { guesseq+=cur+v[0]+v[j]; } guesseq+=cur+v[1]; int ans=press(guesseq); if (ans==i) { cur+=v[2]; } else if (ans==i+1) { cur+=v[1]; } else { assert(ans==i+2); cur+=v[0]; } //cout <<i << " " << cur.size() << endl; } string cur2 = cur; cur2.push_back('A'); cur2+=cur; cur2.push_back('B'); int ans = press(cur2); string cur3 = cur; cur3.push_back('A'); cur3+=cur; cur3.push_back('X'); int ans2 = press(cur3); int b1=ans!=N; int b2=ans2!=N; // cout << ans << " " << ans2 << endl; cur.push_back("ABXY"[2*b1+b2]); return cur; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...