제출 #583943

#제출 시각아이디문제언어결과실행 시간메모리
583943LIF콤보 (IOI18_combo)C++14
5 / 100
1 ms208 KiB
#include "combo.h" #include<bits/stdc++.h> std::string guess_sequence(int N) { std::string p = ""; int n = N; char k[4] = {'A','B','X','Y'}; int first=999; for(int i=0;i<3;i++) { std:: string ss = p; ss = ss + k[i]; int kk = press(ss); if(kk == 1) { first = i; break; } } int check1=0,check2=0; if(first == 999 )//that means first haven't been changed { first = 3; } p = p + k[first]; int all=0; if(first == 3) { all = 2; } else { all = 3; } for (int i = 1; i < n-1;i++) { std::string tt = p; std::string ss=""; int kk = 0; for(int j = 0;j < all; j++) { tt = p; if(j == first)continue; if(kk == 0) { check1 = j; tt += k[j]; ss += tt; } else { check2 = j; tt += k[j]; std::string xxx= tt; for(int pk=0;pk<4;pk++) { if(pk==first)continue; tt = xxx + k[pk]; ss+= tt; } } kk++; } int ans= press(ss); if(ans == i+1) { p = p + k[check1]; } else { if(ans == i+2) { p = p+k[check2]; } else { for(int j=0;j<4;j++) { if(j!=check1&&j!=check2&&j!=first) { p = p + k[j]; } } } } } int flag=0; for(int j=0;j<3;j++) { std::string ss = p; if(j == first )continue; ss += k[j]; if(press(ss) == n) { flag=1; p = p+k[j]; break; } } if(flag==0) { p = p + k[3]; } return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...