제출 #861840

#제출 시각아이디문제언어결과실행 시간메모리
861840imarn콤보 (IOI18_combo)C++14
100 / 100
17 ms1984 KiB
#include<bits/stdc++.h> int press(std::string p); std::string guess_sequence(int N){ std::string ans=""; if(N==0)return ans; char s[4]; if(N==1){ if(press("A")==1)ans="A",s[0]='A',s[1]='B',s[2]='X',s[3]='Y'; else if(press("B")==1)ans="B",s[0]='B',s[1]='A',s[2]='X',s[3]='Y'; else if(press("X")==1)ans="X",s[0]='X',s[1]='B',s[2]='A',s[3]='Y'; else ans="Y",s[0]='Y',s[1]='B',s[2]='X',s[3]='A'; return ans; } int x=press("AXB"); if(x==0){ ans="Y",s[0]='Y',s[1]='B',s[2]='X',s[3]='A'; } else if(x==1){ int y=press("AYABB"); if(y==0)ans="X",s[0]='X',s[1]='B',s[2]='A',s[3]='Y'; else if(y==1)ans="B",s[0]='B',s[1]='A',s[2]='X',s[3]='Y'; else if(y>1)ans="A",s[0]='A',s[1]='B',s[2]='X',s[3]='Y'; } else if(x==2){ int y=press("AX"); if(y==1)ans="X",s[0]='X',s[1]='B',s[2]='A',s[3]='Y'; else if(y==2)ans="A",s[0]='A',s[1]='B',s[2]='X',s[3]='Y'; } else { ans="A",s[0]='A',s[1]='B',s[2]='X',s[3]='Y'; } for(int i=2;i<=N-1;i++){ std::string now1 = ans;now1+=s[1]; std::string now2 = ans;now2+=s[2];now2+=s[1]; std::string now3 = ans;now3+=s[2];now3+=s[2]; std::string now4 = ans;now4+=s[2];now4+=s[3]; std::string tt = now1+now2+now3+now4; int x = press(tt); if(x==i-1)ans = ans+s[3]; else if(x==i)ans = ans+s[1]; else ans = ans+s[2]; } std::string tt1=ans;tt1+=s[1]; std::string tt2=ans;tt2+=s[2]; if(press(tt1)==N){ return tt1; } else if(press(tt2)==N){ return tt2; } else{ ans+=s[3];return ans; } }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:52: warning: 's[3]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   36 |         std::string now4 = ans;now4+=s[2];now4+=s[3];
      |                                                    ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...