제출 #333577

#제출 시각아이디문제언어결과실행 시간메모리
333577nicholask콤보 (IOI18_combo)C++14
100 / 100
51 ms644 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; char c[4]={'A','B','X','Y'}; string guess_sequence(int n){ string ans=""; for (int i=1; i<=n; i++){ int fc; if (i==1){ if (press("AB")){; if (press("A")){ ans+='A'; fc=0; } else { ans+='B'; fc=1; } } else { if (press("X")){ ans+='X'; fc=2; } else { ans+='Y'; fc=3; } } continue; } if (i==n){ string q=ans; q+=c[(fc+1)%4]; if (press(q)==n) ans+=c[(fc+1)%4]; else { q.pop_back(); q+=c[(fc+2)%4]; if (press(q)==n) ans+=c[(fc+2)%4]; else ans+=c[(fc+3)%4]; } continue; } string q=""; q+=ans; q+=c[(fc+1)%4]; q+=c[(fc+1)%4]; q+=ans; q+=c[(fc+1)%4]; q+=c[(fc+2)%4]; q+=ans; q+=c[(fc+1)%4]; q+=c[(fc+3)%4]; q+=ans; q+=c[(fc+2)%4]; int d=press(q); if (d==ans.size()+2) ans+=c[(fc+1)%4]; else if (d==ans.size()+1) ans+=c[(fc+2)%4]; else ans+=c[(fc+3)%4]; } return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:54:8: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |   if (d==ans.size()+2) ans+=c[(fc+1)%4];
      |       ~^~~~~~~~~~~~~~
combo.cpp:55:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |   else if (d==ans.size()+1) ans+=c[(fc+2)%4];
      |            ~^~~~~~~~~~~~~~
combo.cpp:35:13: warning: 'fc' may be used uninitialized in this function [-Wmaybe-uninitialized]
   35 |     q+=c[(fc+2)%4];
      |          ~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...