제출 #574565

#제출 시각아이디문제언어결과실행 시간메모리
574565KrisjanisP콤보 (IOI18_combo)C++14
97 / 100
30 ms524 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; string guess_sequence(int N) { if(N==2) { ll w = press("AB"); if(w>=1) { if(w==2) return "AB"; w = press("AX"); if(w==2) return "AX"; else if(w==1) return "AY"; w = press("BA"); if(w==2) return "BA"; w = press("BX"); if(w==2) return "BX"; return "BY"; } else { ll w = press("XXA"); if(w==0) { if(press("YA")==2) return "YA"; if(press("YB")==2) return "YB"; else return "YX"; } else if(w==1) { if(press("XA")==2) return "XA"; if(press("XB")==2) return "XB"; else return "XY"; } else return "XA"; } } 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"; } char a[4] = {'A','B','X','Y'}; for(ll i=res.size();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; } } if(res.size()!=N) { 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:100:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  100 |   if(res.size()!=N)
      |      ~~~~~~~~~~^~~
combo.cpp:86:33: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
   86 |         if(a[j]==res[0]||a[j]==f||a[j]==s) continue;
      |            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...