제출 #491338

#제출 시각아이디문제언어결과실행 시간메모리
491338cosmic콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; char buttons[4]={'A','B','X','Y'}; char firstch; char next(char w){ int first=-1; for(int i=0;i<4;i++){ if(buttons[i]==firstch) first=i; } return next((first+w)%4); } std::string guess_sequence(int N) { /* std::string p = ""; for (int i = 0; i < 4 * N; ++i) { p += 'A'; } int coins = press(p); std::string S = ""; for (int i = 0; i < N; ++i) { S += 'A'; }*/ string s=" "; if(press("AB")>=1){ if(press("A")==1){ s+="A"; }else s+="B"; }else{ if(press("X")==1) s+="X"; else s+="Y"; } firstch=s[0]; while((int)s.size()<N-1){ string quer=s+next(1); quer+=s+next(2)+next(1); quer+=s+next(2)+next(2); quer+=s+next(2)+next(3); int x=press(quer); if(x==s.size()+1) s+=next(3); else if(x==s.size()+2) s+=next(1); else s+=next(2); } if(press(s+next(1))==N) s+=next(1); else if(press(s+next(2))==N) s+=next(2); else s+=next(3); return N; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:40:9: 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(x==s.size()+1) s+=next(3);
      |        ~^~~~~~~~~~~~
combo.cpp:41:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |     else if(x==s.size()+2) s+=next(1);
      |             ~^~~~~~~~~~~~
combo.cpp:47:10: error: could not convert 'N' from 'int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   47 |   return N;
      |          ^
      |          |
      |          int