제출 #714709

#제출 시각아이디문제언어결과실행 시간메모리
714709bin9638콤보 (IOI18_combo)C++17
100 / 100
38 ms660 KiB
#include<bits/stdc++.h> #ifndef SKY #include "combo.h" #endif // SKY using namespace std; #define N 510 #define ll long long #define ii pair<int,int> #define fs first #define sc second #define pb push_back #define iii pair<int,ii> #ifdef SKY string s; int press(string p) { //cout<<s<<" "<<p<<endl; for(int sz=s.size();sz>=1;sz--) { for(int i=0;i+sz-1<p.size();i++) if(s.substr(0,sz)==p.substr(i,sz)) return sz; } return 0; } #endif vector<char>kt; string guess_sequence(int n) { char start; if(press("XY")==0) { if(press("A")==0) start='B'; else start='A'; }else { if(press("X")==0) start='Y'; else start='X'; } vector<char>cc={'A','B','X','Y'}; for(auto ch:cc) if(ch!=start) kt.pb(ch); string kq=""; kq.pb(start); for(int i=1;i<n-1;i++) { string ask=""; ask+=kq+kt[0]; ask+=kq+kt[1]+kt[0]+kq+kt[1]+kt[1]+kq+kt[1]+kt[2]; int val=press(ask); if(val==kq.size()) { kq.pb(kt[2]); continue; } if(val==kq.size()+1) { kq.pb(kt[0]); continue; } if(val==kq.size()+2) { kq.pb(kt[1]); continue; } } if(n==1) return kq; if(press(kq+kt[0]+kq+kt[1])==kq.size()+1) { if(press(kq+kt[0])==kq.size()+1) kq.pb(kt[0]); else kq.pb(kt[1]); }else kq.pb(kt[2]); return kq; } #ifdef SKY int main() { freopen("A.inp","r",stdin); freopen("A.out","w",stdout); ios::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL); cin>>s; cout<<(s==guess_sequence(s.size())); return 0; } #endif // SKY

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:59:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   59 |         if(val==kq.size())
      |            ~~~^~~~~~~~~~~
combo.cpp:64:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         if(val==kq.size()+1)
      |            ~~~^~~~~~~~~~~~~
combo.cpp:69:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   69 |         if(val==kq.size()+2)
      |            ~~~^~~~~~~~~~~~~
combo.cpp:77:32: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   77 |     if(press(kq+kt[0]+kq+kt[1])==kq.size()+1)
      |        ~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~
combo.cpp:79:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   79 |         if(press(kq+kt[0])==kq.size()+1)
      |            ~~~~~~~~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...