Submission #584227

#TimeUsernameProblemLanguageResultExecution timeMemory
584227LIFCombo (IOI18_combo)C++14
100 / 100
35 ms668 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; std::string ss= p; ss = ss + k[0]; ss = ss + k[1]; if(press(ss) >=1) //that means the first place can be A or B { ss = p; ss = ss + k[0]; if(press(ss) ==1) { p = p +k[0]; first = 0; } else { p = p + k[1]; first = 1; } } else //that means the first plavc { ss = p; ss = ss + k[2]; if(press(ss) == 1) { p = p +k[2]; first =2; } else { p = p +k[3]; first = 3; } } 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; if(n!=1) { for(int j=0;j<all;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 &&first == 3 &&n!=1) { flag = 1; p = p + k[2]; } } if(flag==0&&n!=1) { p = p + k[3]; } return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...