Submission #1007218

#TimeUsernameProblemLanguageResultExecution timeMemory
1007218christinelynnCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include <string> #include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string ans; int val=press("AB"), find; if(val>0) { int cek=press("A"); if(cek==0) { ans+="B"; find=1; } else { ans+="A"; find=0; } } else { int cek=press("X"); if(cek==0) { ans+="Y"; find=3; } else { ans+="X"; find=2; } } else if(find==1) { for(int i=2; i<N; i++) { string que=ans; que=que+ans+"YY"; que=que+ans+"YX"; que=que+ans+"YA"; que=que+ans+"X"; val=press(que); if(val==i)ans+="X"; else if(val==i-1)ans+="A"; else ans+="Y"; } string que; que=ans+"A"; if(val==N)return que; que=ans+"X"; if(val==N)return que; else return ans+"Y"; } else if(find==2) { for(int i=2; i<N; i++) { string que=ans; que=que+ans+"YY"; que=que+ans+"YB"; que=que+ans+"YA"; que=que+ans+"B"; val=press(que); if(val==i)ans+="B"; else if(val==i-1)ans+="A"; else ans+="Y"; } string que; que=ans+"A"; if(val==N)return que; que=ans+"B"; if(val==N)return que; else return ans+"Y"; } else if(find==3) { for(int i=2; i<N; i++) { string que=ans; que=que+ans+"XX"; que=que+ans+"XB"; que=que+ans+"XA"; que=que+ans+"B"; val=press(que); if(val==i)ans+="B"; else if(val==i-1)ans+="A"; else ans+="X"; } string que; que=ans+"A"; if(val==N)return que; que=ans+"B"; if(val==N)return que; else return ans+"X"; } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:3: error: 'else' without a previous 'if'
   37 |   else if(find==1)
      |   ^~~~
combo.cpp:7:10: warning: control reaches end of non-void function [-Wreturn-type]
    7 |   string ans;
      |          ^~~