제출 #366210

#제출 시각아이디문제언어결과실행 시간메모리
366210algorithm16콤보 (IOI18_combo)C++14
100 / 100
56 ms616 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("AB"); if(x) { if(press("A")) s+="A"; else s+="B"; } else { if(press("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+="B"; } 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; }*/

컴파일 시 표준 에러 (stderr) 메시지

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:45:7: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |   if(x==s.size()+1) {
      |      ~^~~~~~~~~~~~
combo.cpp:50:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   50 |   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...