제출 #574555

#제출 시각아이디문제언어결과실행 시간메모리
574555KrisjanisP콤보 (IOI18_combo)C++14
97 / 100
35 ms688 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; string guess_sequence(int N) { string res = ""; if(press("AB")>=1) { if(press("A")==1) res="A"; else res="B"; } else { if(press("X")==1) res="X"; else res="Y"; } if(N==1) return res; char a[4] = {'A','B','X','Y'}; for(ll i=1;i<N-1;i++) { string query = ""; char f, s; for(ll j=0;j<4;j++) { if(a[j]==res[0]) continue; query += res; query += a[j]; f = a[j]; break; } for(ll j=0;j<4;j++) { if(a[j]==res[0]||a[j]==f) continue; for(ll k=0;k<4;k++) { if(a[k]==res[0]) continue; query+=res; query+=a[j]; query+=a[k]; } s = a[j]; break; } ll w = press(query); if(w==(ll)res.size()) { for(ll j=0;j<4;j++) { if(a[j]==res[0]||a[j]==f||a[j]==s) continue; res += a[j]; break; } } else if(w==(ll)res.size()+1) { res += f; } else if(w==(ll)res.size()+2) { res += s; } } bool found = false; for(ll i=0;i<3;i++) { if(a[i]==res[0]) continue; ll w = press(res+a[i]); if(w!=N) continue; found = true; res += a[i]; break; } if(!found) res+=a[3]; return res; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:52:33: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
   52 |         if(a[j]==res[0]||a[j]==f||a[j]==s) continue;
      |            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...