Submission #160296

#TimeUsernameProblemLanguageResultExecution timeMemory
160296LKMSCombo (IOI18_combo)C++11
100 / 100
57 ms612 KiB
#include "combo.h" #include <string> #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string p="AB"; string S=""; int indice=0; int res=press(p); if(res>=1){ p='A'; res=press(p); if(res==1){ ///A S+='A'; }else{ S+='B'; } }else{ p='X'; res=press(p); if(res==1){ S+='X'; }else{ S+='Y'; } } ///Primera letra for(int i=2;i<N;i++){ if(S[0]=='A'){ p=S+'B'+S+"XB"+S+"XX"+S+"XY"; res=press(p); if(res==i){ S+='B'; } if(res==(i+1)){ S+='X'; } if(res==(i-1)){ S+='Y'; } } if(S[0]=='B'){ p=S+'A'+S+"XA"+S+"XX"+S+"XY"; res=press(p); if(res==i){ S+='A'; } if(res==(i+1)){ S+='X'; } if(res==(i-1)){ S+='Y'; } } if(S[0]=='X'){ p=S+'A'+S+"BA"+S+"BB"+S+"BY"; res=press(p); if(res==i){ S+='A'; } if(res==(i+1)){ S+='B'; } if(res==(i-1)){ S+='Y'; } } if(S[0]=='Y'){ p=S+'A'+S+"XA"+S+"XB"+S+"XX"; res=press(p); if(res==i){ S+='A'; } if(res==(i+1)){ S+='X'; } if(res==(i-1)){ S+='B'; } } } if(N>1){ if(S[0]=='A'){ p=S+'B'+S+'X'; res=press(p); if(res==N){ p=S+'B'; res=press(p); if(res==N){ S+='B'; }else{ S+='X'; } }else{ S+='Y'; } } if(S[0]=='B'){ p=S+'A'+S+'X'; res=press(p); if(res==N){ p=S+'A'; res=press(p); if(res==N){ S+='A'; }else{ S+='X'; } }else{ S+='Y'; } } if(S[0]=='X'){ p=S+'B'+S+'A'; res=press(p); if(res==N){ p=S+'B'; res=press(p); if(res==N){ S+='B'; }else{ S+='A'; } }else{ S+='Y'; } } if(S[0]=='Y'){ p=S+'B'+S+'A'; res=press(p); if(res==N){ p=S+'B'; res=press(p); if(res==N){ S+='B'; }else{ S+='A'; } }else{ S+='X'; } } } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:9: warning: unused variable 'indice' [-Wunused-variable]
    9 |     int indice=0;
      |         ^~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...