Submission #245717

#TimeUsernameProblemLanguageResultExecution timeMemory
245717uacoder123Combo (IOI18_combo)C++14
100 / 100
40 ms708 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { int n=N; string s=""; vector<string> v={"A","B","X","Y"}; if(n>=2) { if(press("AB")>=1) { if(press("A")) { s+="A"; string s1="A"; v.erase(v.begin()+0); } else { v.erase(v.begin()+1); s+="B"; } } else { if(press("X")) { v.erase(v.begin()+2); s+="X"; } else { v.erase(v.begin()+3); s+="Y"; } } v.push_back(s); for(int i=0;i<n-2;++i) { int x=press(s+v[0]+s+v[1]+v[0]+s+v[1]+v[1]+s+v[1]+v[2]); if(x==s.size()+1) s+=v[0]; else if(x==s.size()+2) s+=v[1]; else s+=v[2]; } } if(press(s+"A"+s+"B")==s.size()+1) { if(press(s+"A")==s.size()+1) s+="A"; else s+="B"; } else { if(press(s+"X")==s.size()+1) s+="X"; else s+="Y"; } return(s); }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |     if(x==s.size()+1)
      |        ~^~~~~~~~~~~~
combo.cpp:44:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |     else if(x==s.size()+2)
      |             ~^~~~~~~~~~~~
combo.cpp:50:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   if(press(s+"A"+s+"B")==s.size()+1)
      |      ~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:52:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |     if(press(s+"A")==s.size()+1)
      |        ~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:59:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |     if(press(s+"X")==s.size()+1)
      |        ~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...