Submission #366207

#TimeUsernameProblemLanguageResultExecution timeMemory
366207algorithm16Combo (IOI18_combo)C++14
0 / 100
24 ms340 KiB
#include<iostream> #include<string> #include<algorithm> #include "combo.h" using namespace std; /*int press(string s) { cout << s << "\n"; int a; cin >> a; return a; }*/ string guess_sequence(int N) { if(N==1) { if(press("A")) return "A"; else if(press("B")) return "B"; else if(press("X")) return "X"; return "Y"; } string s=""; int x=0; /*x=press("AABABBBXBY"); if(x==1) s+="A"; else if(x==2) s+="B"; else { x=press("XXYAYBYXYY"); if(x==1) s+="X"; else if(x==2) s+="Y"; }*/ x=press("A"); if(x) s+="A"; else { x=press("B"); if(x) s+="B"; else { x=press("X"); if(x) s+="X"; else s+="Y"; } } for(int i=1;i<N-1;i++) { string s2=""; if(s[0]=='A') s2=s+"B"+s+"XB"+s+"XX"+s+"XY"; if(s[0]=='B') s2=s+"A"+s+"XA"+s+"XX"+s+"XY"; if(s[0]=='X') s2=s+"A"+s+"BA"+s+"BB"+s+"BY"; if(s[0]=='Y') s2=s+"A"+s+"BA"+s+"BB"+s+"BX"; int x=press(s2); if(x==s.size()+1) { if(s[0]=='A') s+="B"; else s+="A"; continue; } else if(x==s.size()+2) { if(s[0]=='A' or s[0]=='B') s+="X"; else s+="A"; } else { if(s[0]=='Y') s+="X"; else s+="Y"; } } if(s[0]=='A') { if(press(s+"B")==N) return s+"B"; if(press(s+"X")==N) return s+"X"; return s+"Y"; } if(s[0]=='B') { if(press(s+"A")==N) return s+"A"; if(press(s+"X")==N) return s+"X"; return s+"Y"; } if(s[0]=='X') { if(press(s+"A")==N) return s+"A"; if(press(s+"B")==N) return s+"B"; return s+"Y"; } if(s[0]=='Y') { if(press(s+"A")==N) return s+"A"; if(press(s+"B")==N) return s+"B"; return s+"X"; } } /*int main() { int n; cin >> n; cout << guess_sequence(n); return 0; }*/

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:47:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   if(x==s.size()+1) {
      |      ~^~~~~~~~~~~~
combo.cpp:52:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   52 |   else if(x==s.size()+2) {
      |           ~^~~~~~~~~~~~
combo.cpp:19:11: warning: control reaches end of non-void function [-Wreturn-type]
   19 |  string s="";
      |           ^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...