제출 #211538

#제출 시각아이디문제언어결과실행 시간메모리
211538Harry464콤보 (IOI18_combo)C++14
5 / 100
1 ms256 KiB
#include <iostream> #include <string> #include <cmath> #include "combo.h" using namespace std; string guess_sequence(int N) { char slovo[4]={'A','B','X','Y'}; int prvoSlovo, odgovor; string s; if(press("AB")) { if(press("A")) prvoSlovo=0; else prvoSlovo=1; } else { if(press("X")) prvoSlovo=2; else prvoSlovo=3; } s+=slovo[prvoSlovo]; for(int i=2;i<N;i++) { odgovor=press(s + slovo[(prvoSlovo+1)%4] + slovo[(prvoSlovo+1)%4] + s + slovo[(prvoSlovo+1)%4] + slovo[(prvoSlovo+2)%4] + s + slovo[(prvoSlovo+1)%4] + slovo[(prvoSlovo+3)%4] + s + slovo[(prvoSlovo+2)%4]); if(odgovor==s.size()) s+=slovo[(prvoSlovo+3)%4]; else if(odgovor==s.size()+1) s+=slovo[(prvoSlovo+2)%4]; else s+=slovo[(prvoSlovo+1)%4]; } if(press(s + slovo[(prvoSlovo+1)%4] + s + slovo[(prvoSlovo+2)%4])>s.size()) { if(press(s+slovo[(prvoSlovo+1)%4])>s.size()) s+=slovo[(prvoSlovo+1)%4]; else s+=slovo[(prvoSlovo+2)%4]; } else { s+=slovo[(prvoSlovo+3)%4]; } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |     if(odgovor==s.size()) s+=slovo[(prvoSlovo+3)%4];
      |        ~~~~~~~^~~~~~~~~~
combo.cpp:34:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     else if(odgovor==s.size()+1) s+=slovo[(prvoSlovo+2)%4];
      |             ~~~~~~~^~~~~~~~~~~~
combo.cpp:38:68: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |   if(press(s + slovo[(prvoSlovo+1)%4] + s + slovo[(prvoSlovo+2)%4])>s.size())
      |      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
combo.cpp:40:39: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     if(press(s+slovo[(prvoSlovo+1)%4])>s.size()) s+=slovo[(prvoSlovo+1)%4];
      |        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...