Submission #529377

#TimeUsernameProblemLanguageResultExecution timeMemory
529377__VariattoCombo (IOI18_combo)C++17
100 / 100
35 ms600 KiB
#include <bits/stdc++.h> #include "combo.h" using namespace std; #define pb push_back #define fi first #define se second #define ll long long /*int press(string p){ cout<<p<<"\n"; int x; cin>>x; return x; }*/ //1-A, 2-B, 3-X, 4-Y string guess_sequence(int n){ string s; if(press("AB")){ if(press("A")) s="A"; else s="B"; } else{ if(press("X")) s="X"; else s="Y"; } if(n==2){ if(s!="A" && press(s+"A")==2) s+='A'; else if(s!="B" && press(s+"B")==2) s+='B'; else if(s=="Y" || (s!="X" && press(s+"X")==2)) s+='X'; else s+='Y'; return s; } for(int i=1; i<=n-1; i++){ if(s[0]=='A'){ string pyt=s+"B"+s+"XB"+s+"XX"+s+"XY"; if(i==n-1) pyt=s+"XB"+s+"XX"+s+"XY"; int a=press(pyt); if(a==s.size()+2 || (i==n-1 && a==s.size()+1)) s+='X'; else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"B")==s.size()+1)) s+='B'; else s+='Y'; } if(s[0]=='B'){ //cout<<"XD"; string pyt=s+"A"+s+"XA"+s+"XX"+s+"XY"; if(i==n-1) pyt=s+"XA"+s+"XX"+s+"XY"; int a=press(pyt); if(a==s.size()+2 || (i==n-1 && a==s.size()+1)) s+='X'; else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1)) s+='A'; else s+='Y'; } if(s[0]=='X'){ string pyt=s+"A"+s+"BA"+s+"BB"+s+"BY"; if(i==n-1) pyt=s+"BA"+s+"BB"+s+"BY"; int a=press(pyt); if(a==s.size()+2 || (i==n-1 && a==s.size()+1)) s+='B'; else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1)) s+='A'; else s+='Y'; } if(s[0]=='Y'){ string pyt=s+"A"+s+"XA"+s+"XB"+s+"XX"; if(i==n-1) pyt=s+"XA"+s+"XB"+s+"XX"; int a=press(pyt); if(a==s.size()+2 || (i==n-1 && a==s.size()+1)) s+='X'; else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1)) s+='A'; else s+='B'; } } return s; } /*int main(){ ios_base::sync_with_stdio(false); cin.tie(0), cout.tie(0); int x; cin>>x; cout<<guess_sequence(x)<<"\n";; } */

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:42:17: 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(a==s.size()+2 || (i==n-1 && a==s.size()+1))
      |                ~^~~~~~~~~~~~
combo.cpp:42:45: 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(a==s.size()+2 || (i==n-1 && a==s.size()+1))
      |                                            ~^~~~~~~~~~~~
combo.cpp:44:22: 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(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"B")==s.size()+1))
      |                     ~^~~~~~~~~~~~
combo.cpp:44:50: 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(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"B")==s.size()+1))
      |                                                 ~^~~~~~~~~~
combo.cpp:44:76: 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(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"B")==s.size()+1))
      |                                                                ~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:55:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             if(a==s.size()+2 || (i==n-1 && a==s.size()+1))
      |                ~^~~~~~~~~~~~
combo.cpp:55:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |             if(a==s.size()+2 || (i==n-1 && a==s.size()+1))
      |                                            ~^~~~~~~~~~~~
combo.cpp:57:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1))
      |                     ~^~~~~~~~~~~~
combo.cpp:57:50: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1))
      |                                                 ~^~~~~~~~~~
combo.cpp:57:76: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1))
      |                                                                ~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:67:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             if(a==s.size()+2 || (i==n-1 && a==s.size()+1))
      |                ~^~~~~~~~~~~~
combo.cpp:67:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             if(a==s.size()+2 || (i==n-1 && a==s.size()+1))
      |                                            ~^~~~~~~~~~~~
combo.cpp:69:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |             else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1))
      |                     ~^~~~~~~~~~~~
combo.cpp:69:50: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |             else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1))
      |                                                 ~^~~~~~~~~~
combo.cpp:69:76: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |             else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1))
      |                                                                ~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:79:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |             if(a==s.size()+2 || (i==n-1 && a==s.size()+1))
      |                ~^~~~~~~~~~~~
combo.cpp:79:45: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |             if(a==s.size()+2 || (i==n-1 && a==s.size()+1))
      |                                            ~^~~~~~~~~~~~
combo.cpp:81:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |             else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1))
      |                     ~^~~~~~~~~~~~
combo.cpp:81:50: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |             else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1))
      |                                                 ~^~~~~~~~~~
combo.cpp:81:76: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |             else if(a==s.size()+1 || (i==n-1 && a==s.size() && press(s+"A")==s.size()+1))
      |                                                                ~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...