Submission #160285

#TimeUsernameProblemLanguageResultExecution timeMemory
160285DavidDamianCombo (IOI18_combo)C++11
100 / 100
50 ms584 KiB
#include<iostream> #include <cstdio> #include <cstdlib> #include <algorithm> #include <string> #include "combo.h" using namespace std; string guess_sequence(int N) ///Guess the combo sequence { string p=""; string Q="AB"; char letter[4]; char l[4]={'A','B','X','Y'}; int answer=press(Q); if(answer>=1){ //We find the first letter in two queries if(press("A")) p+='A'; else p+='B'; } else{ if(press("X")) p+='X'; else p+='Y'; } int j=0; for(int i=0;i<4;i++){ //Ans we eliminate it from possible letters if(p[0]!=l[i]){ letter[j++]=l[i]; } } for(int i=2;i<N;i++){ //For each letter we guess it making a query with 3 different return values (one for each letter) Q=p+letter[0]+p+letter[1]+letter[0]+p+letter[1]+letter[1]+p+letter[1]+letter[2]; answer=press(Q); if(answer==i-1){ p+=letter[2]; } else if(answer==i){ p+=letter[0]; } else if(answer==i+1){ p+=letter[1]; } } if(N>1){ //We guess the last letter with two queries if(press(p+letter[0])==N){ p+=letter[0]; } else if(press(p+letter[1])==N){ p+=letter[1]; } else{ p+=letter[2]; } } return p; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...