Submission #1007447

#TimeUsernameProblemLanguageResultExecution timeMemory
1007447devariaotaCombo (IOI18_combo)C++17
100 / 100
19 ms1312 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; } } if(N==1)return ans; if(find==0) { for(int i=2; i<N; i++) { string que; que=que+ans+"YY"; que=que+ans+"YX"; que=que+ans+"YB"; que=que+ans+"X"; val=press(que); if(val==i)ans+="X"; else if(val==i-1)ans+="B"; else ans+="Y"; } string que; que=ans+"B"; val=press(que); if(val==N)return que; que=ans+"X"; val=press(que); if(val==N)return que; else return ans+"Y"; } else if(find==1) { for(int i=2; i<N; i++) { string que; 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"; val=press(que); if(val==N)return que; que=ans+"X"; val=press(que); if(val==N)return que; else return ans+"Y"; } else if(find==2) { for(int i=2; i<N; i++) { string que; 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"; val=press(que); if(val==N)return que; que=ans+"B"; val=press(que); if(val==N)return que; else return ans+"Y"; } else if(find==3) { for(int i=2; i<N; i++) { string que; 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"; val=press(que); if(val==N)return que; que=ans+"B"; val=press(que); if(val==N)return que; else return ans+"X"; } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:10: warning: control reaches end of non-void function [-Wreturn-type]
    8 |   string ans;
      |          ^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...