Submission #891314

#TimeUsernameProblemLanguageResultExecution timeMemory
891314preskoCombo (IOI18_combo)C++14
100 / 100
13 ms1912 KiB
#include "combo.h" //#include<iostream> std::string guess_sequence(int N) { char poss[4]; std::string s="",p=""; char first,use1,use2,use3; p="AB"; poss[0]='A'; poss[1]='B'; poss[2]='X'; poss[3]='Y'; int res=press(p); if(res>=1) { p="A"; res=press(p); if(res==1)s="A"; else s="B"; } else { p="X"; res=press(p); if(res==1)s="X"; else s="Y"; } if(N==1)return s; p=""; first=s[0]; if(first=='A'){use1='B';use2='X';use3='Y';} else { use1='A'; if(first=='B'){use2='X';use3='Y';} else { use2='B'; if(first=='X')use3='Y'; else use3='X'; } } //std::cout<<s<<"_s "<<use1<<" "<<use2<<" "<<use3<<"\n"; int prev=res; for(int i=1;i<N-1;i++) { p=s+use1; std::string curr=""; for(int j=0;j<4;j++) { if(poss[j]!=first)curr=curr+s+use2+poss[j]; } p=p+curr; //std::cout<<p<<" "; int ret=press(p); //std::cout<<ret<<"r\n"; if(ret-i==0)s=s+use3; else if(ret-i==1)s=s+use1; else s=s+use2; //std::cout<<s<<"_s\n"; prev=ret; } p=s+use1; res=press(p); if(res>N-1)s=s+use1; else { p=s+use2; res=press(p); if(res>N-1)s=s+use2; else s=s+use3; } return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:46:9: warning: variable 'prev' set but not used [-Wunused-but-set-variable]
   46 |     int prev=res;
      |         ^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...