Submission #1043168

#TimeUsernameProblemLanguageResultExecution timeMemory
1043168sofpp콤보 (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int N) { string p = "";string S = ""; int coins=press("AB"); if(coins==2){ S+='A';S+='B'; } else if(coins==1){ coins+=press("A"); if(coins>1){ S+='A'; }else{ S+='B'; } } else{ coins=press("XY"); if(coins==2){ S+='X';S+='Y'; } else if(coins==1){ coins+=press("X"); if(coins>1){ S+='X'; } else{ S+='Y'; } } } string character=S; if(coins==2){ string p = ""; for(int i=2;i<N-1;i++){ if(character=="A"){ p+=S; p+='B';p+=S; p+="XY";;p+=S;p+="XB";p+=S;;p+="XX"; if(press(p)==(int)S.size()+2){ S+='B'; } else if(press(p)==(int)S.size()+3){ S+='X'; } else{ S+='Y'; } } if(character=="B"){ p+=S; p+='A';p+=S; p+="XA";;p+=S;p+="XY";p+=S;;p+="XX"; if(press(p)==(int)S.size()+2){ S+='A'; } else if(press(p)==(int)S.size()+3){ S+='X'; } else{ S+='Y'; } } if(character=="X"){ p+=S; p+='A';p+=S; p+="BA";;p+=S;p+="BY";p+=S;;p+="BB"; if(press(p)==(int)S.size()+2){ S+='A'; } else if(press(p)==(int)S.size()+3){ S+='B'; } else{ S+='Y'; } } if(character=="Y"){ p+=S; p+='A';p+=S; p+="BA";;p+=S;p+="BX";p+=S;;p+="BB"; if(press(p)==(int)S.size()+2){ S+='A'; } else if(press(p)==(int)S.size()+3){ S+='B'; } else{ S+='X'; } } } } else{ string p = ""; for(int i=1;i<N-1;i++){ if(character=="A"){ p+=S; p+='B';p+=S; p+="XY";;p+=S;p+="XB";p+=S;;p+="XX"; if(press(p)==(int)S.size()+2){ S+='B'; } else if(press(p)==(int)S.size()+3){ S+='X'; } else{ S+='Y'; } } if(character=="B"){ p+=S; p+='A';p+=S; p+="XA";;p+=S;p+="XY";p+=S;;p+="XX"; if(press(p)==(int)S.size()+2){ S+='A'; } else if(press(p)==(int)S.size()+3){ S+='X'; } else{ S+='Y'; } } if(character=="X"){ p+=S; p+='A';p+=S; p+="BA";;p+=S;p+="BY";p+=S;;p+="BB"; if(press(p)==(int)S.size()+2){ S+='A'; } else if(press(p)==(int)S.size()+3){ S+='B'; } else{ S+='Y'; } } if(character=="Y"){ p+=S; p+='A';p+=S; p+="BA";;p+=S;p+="BX";p+=S;;p+="BB"; if(press(p)==(int)S.size()+2){ S+='A'; } else if(press(p)==(int)S.size()+3){ S+='B'; } else{ S+='X'; } } } } string p = ""; if(character=="A"){ p+=S;p+="B";p+=S;p+='X'; if(press(p)== N){ string c=S+'B'; if(press(c)==N){ S+='B'; } else{ S+='X'; } } else{ S+='Y'; } } if(character=="B"){ p+=S;p+="A";p+=S;p+='X'; if(press(p)== N){ string c=S+'A'; if(press(c)==N){ S+='A'; } else{ S+='X'; } } else{ S+='Y'; } } if(character=="A"){ p+=S;p+="A";p+=S;p+='B'; if(press(p)== N){ string c=S+'A'; if(press(c)==N){ S+='A'; } else{ S+='B'; } } else{ S+='Y'; } } if(character=="Y"){ p+=S;p+="A";p+=S;p+='B'; if(press(p)== N){ string c=S+'A'; if(press(c)==N){ S+='A'; } else{ S+='B'; } } else{ S+='X'; } } // int coins = press(p); // for (int i = 0; i < N; ++i) { // S += 'A'; // } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:142:10: error: redeclaration of 'std::string p'
  142 |   string p = "";
      |          ^
combo.cpp:6:10: note: 'std::string p' previously declared here
    6 |   string p = "";string S = "";
      |          ^