제출 #869451

#제출 시각아이디문제언어결과실행 시간메모리
869451adkjt콤보 (IOI18_combo)C++14
10 / 100
21 ms2072 KiB
#include "combo.h" #include<bits/stdc++.h> using namespace std; string guess_sequence(int N) { //string p = ""; char ot[3]; string ans; if(press("A")==1) ans="A",ot[0]='B',ot[1]='X',ot[2]='Y'; else if(press("B")==1) ans="B",ot[0]='A',ot[1]='X',ot[2]='Y'; else if(press("X")==1) ans="X",ot[0]='B',ot[1]='A',ot[2]='Y'; else if(press("Y")==1) ans="Y",ot[0]='B',ot[1]='X',ot[2]='A'; //int coins = press(p); string S; if(N==1) return ans; for (int i = 2; i <N; ++i) { S = ans+ot[0]+ans+ot[1]+ot[0]+ans+ot[1]+ot[1]+ans+ot[1]+ot[2]; //cout<<S<<' '; if(press(S)==i-1) ans+=ot[2]; else if(press(S)==i) ans+=ot[0]; else ans+=ot[1]; //cout<<ans<<'\n'; } if(press(ans+ot[0])==N) ans+=ot[0]; else if( press(ans+ot[1])==N) ans+=ot[1]; else ans+=ot[2]; return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:20:67: warning: 'ot[2]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   20 |     S   = ans+ot[0]+ans+ot[1]+ot[0]+ans+ot[1]+ot[1]+ans+ot[1]+ot[2];
      |                                                                   ^
combo.cpp:28:24: warning: 'ot[1]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   28 | else if( press(ans+ot[1])==N) ans+=ot[1];
      |                        ^
combo.cpp:27:18: warning: 'ot[0]' may be used uninitialized in this function [-Wmaybe-uninitialized]
   27 | if(press(ans+ot[0])==N) ans+=ot[0];
      |                  ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...