제출 #574559

#제출 시각아이디문제언어결과실행 시간메모리
574559KrisjanisP콤보 (IOI18_combo)C++14
5 / 100
1 ms208 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"; else if(w==1) { if(press("AX")) return "AX"; else return "AY"; } else{ w = press("BA"); if(w==2) return "BA"; else { if(press("BX")==2) return "BX"; else return "BY"; } } } else { // XY w = press("XA"); if(w==2) return "XA"; else if(w==1){ if(press("XB")==2) return "XB"; else return "XY"; } else{ w = press("YA"); if(w==2) return "YA"; else { if(press("YB")==2) return "YB"; else return "YX"; } } } } 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:107:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  107 |   if(res.size()!=N)
      |      ~~~~~~~~~~^~~
combo.cpp:93:33: warning: 's' may be used uninitialized in this function [-Wmaybe-uninitialized]
   93 |         if(a[j]==res[0]||a[j]==f||a[j]==s) continue;
      |            ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...