Submission #161093

#TimeUsernameProblemLanguageResultExecution timeMemory
161093giorgikobCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h" #include <string> std::string guess_sequence(int N) { std::string S = ""; int x = press("AB"); if(x == 1){ x = press("A"); if(x==1){ S += 'A'; } else { S += 'B'; } } else { x = press("X"); if(x==1){ S += "X"; } else { S += "Y"; } } std::string c1,c2,c3; if(S=="X") c1 = "A", c2 = "B", c3 = "Y"; if(S=="Y") c1 = "A", c2 = "B", c3 = "X"; if(S=="A") c1 = "B", c2 = "X", c3 = "Y"; if(S=="B") c1 = "A", c2 = "X", c3 = "Y"; for(int i=1;i<N-1;i++){ std::string p = S+c1+S+c2+c1+S+c2+c2+S+c2+c3; int x = (p); if(x==(int)S.size()); S += c3; if(x==(int)S.size()+1) S += c1; if(x==(int)S.size()+2) S += c2; } std::string p = S + c1 + S + c2; int x = press(p); if(x == N){ p = S + c1; x = press(p); if(x==N){ S += c1; } else { S += c2; } } else { S += c3; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:31:18: error: cannot convert 'std::string' {aka 'std::__cxx11::basic_string<char>'} to 'int' in initialization
   31 |         int x = (p);
      |                 ~^~
      |                  |
      |                  std::string {aka std::__cxx11::basic_string<char>}
combo.cpp:41:9: error: redeclaration of 'int x'
   41 |     int x = press(p);
      |         ^
combo.cpp:6:9: note: 'int x' previously declared here
    6 |     int x = press("AB");
      |         ^