제출 #1142562

#제출 시각아이디문제언어결과실행 시간메모리
1142562qwerty13579Combo (IOI18_combo)C++20
0 / 100
0 ms408 KiB
#include "bits/stdc++.h" #include "combo.h" using namespace std; std::string guess_sequence(int n) { string pb = "ABXY"; string possibilities = ""; string p = ""; string s = ""; if (press("AB") > 0){ // if AB is 1 if (press("A") == 1) p += 'A'; // if A is 1 add to s A else p += 'B'; // else add to s B } else if (press("X") == 1) p += 'X'; // if X is 1 add to s X else p+='Y'; // else add Y s=p; // add to p the prefix found for (int i=0;i<pb.size();++i){ if (pb[i]==s[0]) continue; possibilities+=pb[i]; // remove the prefix from the possibilities } // generate the string to ask until press(p) == n // p and add to p the first character in possibilities that's not the prefix, then add the second one and append to the second one all other three that's not the prefix int last_ans = 1; while(true) { if (p.size()==n-1){ break; } string toAdd = ""; // str to add to not modify p yet toAdd+=possibilities[0]; // add first character toAdd+=s[0]; // add prefix toAdd+=possibilities[1]; // add second character // to second character add all the possibilities for(int i=0;i<possibilities.size();++i){ toAdd+=possibilities[i]; if (i<possibilities.size()-1){ toAdd+=s[0]; toAdd+=possibilities[1]; } } // ask int ans = press(p + toAdd); // if we get 1, the sole character is good if (ans-last_ans==1){ p+=possibilities[0]; } else if (ans-last_ans > 1){ // else if we get 2 the second character is good p+=possibilities[1]; } else { // else it's the one we didn't ask of p+=possibilities[2]; } // update last ans; last_ans = ans; } if(press(p + possibilities[0]) - last_ans == 1) p+=possibilities[0]; else if(press(p + possibilities[1]) - last_ans == 1) p+=possibilities[1]; else p+=possibilities[2]; s=p; return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...