Submission #873621

#TimeUsernameProblemLanguageResultExecution timeMemory
873621maxFedorchukCombo (IOI18_combo)C++14
100 / 100
15 ms2120 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; /* int press(string p) { cout<<p<<endl; cout.flush(); int rt; cin>>rt; return rt; } */ string guess_sequence(int N) { string alsym[4]={"A","B","X","Y"}; string pot[3]; int frs; if(press(alsym[0]+alsym[1])) { if(press(alsym[0])) { frs=0; pot[0]="B"; pot[1]="X"; pot[2]="Y"; } else { frs=1; pot[0]="A"; pot[1]="X"; pot[2]="Y"; } } else { if(press(alsym[2])) { frs=2; pot[0]="A"; pot[1]="B"; pot[2]="Y"; } else { frs=3; pot[0]="A"; pot[1]="B"; pot[2]="X"; } } string res=alsym[frs]; if(N==1) { return res; } for(int i=2;i<N;i++) { string zap=(res+pot[0]+pot[0])+(res+pot[0]+pot[1])+(res+pot[0]+pot[2])+(res+pot[1]+alsym[frs]); int rt=press(zap); if((res.size()+2)==rt) { res=res+pot[0]; } else { if((res.size()+1)==rt) { res=res+pot[1]; } else { res=res+pot[2]; } } } if(press(res+pot[0]+res+pot[1])==N) { if(press(res+pot[0])==N) { res=res+pot[0]; } else { res=res+pot[1]; } } else { res=res+pot[2]; } return res; } /* int main() { cin.tie(0); ios_base::sync_with_stdio(0); string s; cin>>s; if(guess_sequence(s.size())==s) { cout<<"Ok\n"; } else { cout<<"No\n"; } return 0; } */

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:71:26: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   71 |         if((res.size()+2)==rt)
      |            ~~~~~~~~~~~~~~^~~~
combo.cpp:77:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   77 |             if((res.size()+1)==rt)
      |                ~~~~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...