Submission #491336

#TimeUsernameProblemLanguageResultExecution timeMemory
491336cfalasCombo (IOI18_combo)C++17
5 / 100
1 ms200 KiB
#include<bits/stdc++.h> using namespace std; #include "combo.h" char letters[4] = {'A','B','X','Y'}; char first; char next(int s){ int fi=-1; for(int i=0;i<4;i++) if(letters[i]==first) fi = i; return letters[(fi + s)%4]; } string guess_sequence(int N) { string s = ""; int x = press("AB"); if(x>=1){ if(x == 2) s = "AB"; else if(press("A")==1) s = "A"; else s = "B"; } else{ if(press("X")==1) s = "X"; else s = "Y"; } first = s[0]; while((int)s.size()<N-1){ string q = s + next(1); q += s + next(2) + next(1); q += s + next(2) + next(2); q += s + next(2) + next(3); //cout<<q<<endl; int x =press(q); if(x==s.size()) s += next(3); else if(x==s.size()+1) s+= next(1); else s+=next(2); } if(press(s+next(1))==N) s+=next(1); else if(press(s+next(2))==N) s+=next(2); else s+=next(3); return s; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |   if(x==s.size()) s += next(3);
      |      ~^~~~~~~~~~
combo.cpp:38:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   else if(x==s.size()+1) s+= next(1);
      |           ~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...