Submission #1142711

#TimeUsernameProblemLanguageResultExecution timeMemory
1142711mifoCombo (IOI18_combo)C++20
100 / 100
7 ms508 KiB
#include "bits/stdc++.h" #include "combo.h" using namespace std; std::string guess_sequence(int n) { string pb = "ABXY"; string possibilities = ""; string p = ""; // prefix : all good if (press("AB") > 0) { if (press("A") == 1) { p += 'A'; } else { p += 'B'; } } else if (press("X") == 1) { p += 'X'; } else { p += 'Y'; } for (int i=0; i<pb.size(); ++i) { if (pb[i] == p[0]) { continue; } possibilities+=pb[i]; } // middle string : problem might be here int last_ans = 1; while(last_ans<n-1) { string toAdd = ""; toAdd+=possibilities[0]; for(int i=0; i<possibilities.size(); ++i) { toAdd+=p; toAdd+=possibilities[1]; toAdd+=possibilities[i]; } int ans = press(p + toAdd); if (ans-last_ans==1) { p+=possibilities[0]; } else if (ans-last_ans > 1) { p+=possibilities[1]; } else { p+=possibilities[2]; } ++last_ans; } if(n==1)return p; // last char : normally all good if(press(p + possibilities[0]) == n) { p+=possibilities[0]; } else if(press(p + possibilities[1]) == n) { p+=possibilities[1]; } else { p+=possibilities[2]; } return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...