Submission #206503

#TimeUsernameProblemLanguageResultExecution timeMemory
206503vardan__02Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include <algorithm> #include <iostream> #include <fstream> #include <cstring> #include <string> #include <vector> #include <cstdio> #include <queue> #include <deque> #include <stack> #include <list> #include <set> #include <map> #include "combo.h" using namespace std; string guess_sequence(int N) { int n=N; string ans=""; string ban=""; int v=0, x; if(n==2) { ans="XX"; x = press("XYYX"); if(x==0) { x = press("ABBA"); if(x==1) { x = press("AXBX"); if(x==1) ans[1]='Y'; else ans[1]='X'; x = press("A"); if(x==1) ans[0]='A'; else ans[0]='B'; } else { x = press("AB"); if(x==2) ans="AB"; else ans="BA"; } } else { if(x==1) { x = press("XAYA"); if(x==1) ans[1]='B'; else ans[1]='A'; x = press("X"); if(x==1) ans[0]='X'; else ans[0]='Y'; } else { x = press("XY"); if(x==2) ans="XY"; else ans="YX"; } } return ans; } x = press("A"); if(x==1) { ban="XYB"; ans="A"; } else { x = press("B"); if(x==1) { ban="XYA"; ans="B"; } else { x = press("X"); if(x==1) { ban="ABY"; ans="X"; } else { x = press("Y"); if(x==1) { ban="ABX"; ans="Y"; } } } } if(n==1) return ans; if(n%2==0) { string s=""; s=ans[0]+ban[0]+ban[1]+ban[0]+ans[0]+ban[1]+ban[0]+ban[1]; x = press(s); if(x==1) ans=ans+ban[2]; else if(x==3) { s=""; s=ans[0]+ban[0]+ban[1]; x = press(s); if(x==3) ans=ans+ban[0]+ban[1]+ban[2]; else ans=ans+ban[1]+ban[0]+ban[2]; } else { s=""; s=ans[0]+ban[0]+ban[2]+ban[0]+ans[0]+ban[1]+ban[2]+ban[1]; x = press(s); if(x==3) { s=""; s=ans[0]+ban[0]; x = press(s); if(x==1) ans=ans+ban[1]; else ans=ans+ban[0]; ans=ans+ban[2]+ban[2]; } else { s=""; s=ans[0]+ban[0]+ban[2]+ban[0]; x = press(s); if(x==4) ans=ans+ban[0]+ban[2]+ban[0]; else ans=ans+ban[1]+ban[2]+ban[1]; } } } while(ans.size()!=n) { s=ans+ban[0]+ban[1]+ans+ban[1]+ban[0]; x = press(s); if(x==ans.size()) { ans=ans+ban[2]; s=ans+ban[0]; x = press(s); if(x==ans.size()+1) ans=ans+ban[0]; else ans=ans+ban[1]; } else { if(x==ans.size()+1) { s=ans+ban[0]+ban[2]; x = press(s); if(x==ans.size()+2) ans=ans+ban[0]+ban[2]; else ans=ans+ban[1]+ban[2]; } else { s=ans+ban[0]+ban[1]; x = press(s); if(x==ans.size()+2) ans=ans+ban[0]+ban[1]; else ans=ans+ban[1]+ban[0]; } } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:158:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  158 |     while(ans.size()!=n)
      |           ~~~~~~~~~~^~~
combo.cpp:160:9: error: 's' was not declared in this scope
  160 |         s=ans+ban[0]+ban[1]+ans+ban[1]+ban[0];
      |         ^
combo.cpp:162:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  162 |         if(x==ans.size())
      |            ~^~~~~~~~~~~~
combo.cpp:167:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  167 |             if(x==ans.size()+1)
      |                ~^~~~~~~~~~~~~~
combo.cpp:174:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  174 |             if(x==ans.size()+1)
      |                ~^~~~~~~~~~~~~~
combo.cpp:178:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  178 |                 if(x==ans.size()+2)
      |                    ~^~~~~~~~~~~~~~
combo.cpp:187:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  187 |                 if(x==ans.size()+2)
      |                    ~^~~~~~~~~~~~~~
combo.cpp:21:9: warning: unused variable 'v' [-Wunused-variable]
   21 |     int v=0, x;
      |         ^