제출 #340265

#제출 시각아이디문제언어결과실행 시간메모리
340265amano_hina콤보 (IOI18_combo)C++14
100 / 100
42 ms524 KiB
#include "combo.h" std::string guess_sequence(int N) { std::string p = ""; std::string p2= ""; std::string ans= ""; int ban; char c[4]; c[0]='A'; c[1]='B'; c[2]='X'; c[3]='Y'; p += c[0]; p += c[1]; int coins = press(p); if(coins>=1) { p.clear(); p+=c[0]; coins = press(p); if(coins==1) { ans+=c[0]; ban=0; } else { ans+=c[1]; ban=1; } } else { p.clear(); p+=c[2]; coins = press(p); if(coins==1) { ans+=c[2]; ban=2; } else { ans+=c[3]; ban=3; } } // 2 steps int pos; int pos2; int pos3; pos=0; if(pos==ban) { pos++; } pos2=pos+1; if(pos2==ban) { pos2++; } pos3=pos2+1; if(pos3==ban) { pos3++; } for(int i=1;i<N-1;i++) { p2.clear(); for(int j=0;j<4;j++) { if(j!=ban) { p2+=ans; p2+=c[pos]; p2+=c[j]; } } p2+=ans; p2+=c[pos2]; coins = press(p2); if(coins==i) { ans+=c[pos3]; } else if(coins==i+1) { ans+=c[pos2]; } else { ans+=c[pos]; } } // n-2 steps if(N==1) { return ans; } else { p2.clear(); p2+=ans; p2+=c[pos]; coins = press(p2); if(coins==N) { std::string S = ""; S+=ans; S+=c[pos]; return S; } p2.clear(); p2+=ans; p2+=c[pos2]; coins = press(p2); if(coins==N) { std::string S = ""; S+=ans; S+=c[pos2]; return S; } std::string S = ""; S+=ans; S+=c[pos3]; return S; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...