제출 #820137

#제출 시각아이디문제언어결과실행 시간메모리
820137MSK17콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> std::string s; std::vector<char> c; int press(std::string); std::string make(std::string cur){ std::string ret; for(int i{}; i < 3; ++i){ ret+=cur; ret.push_back(c[0]); ret.push_back(c[i]); } ret+=cur; ret.push_back(c[1]); return ret; } std::string guess_sequence(int n){ int val=press("AB"); if(val) s=(press("A")==1?"A":"B"); else s=(press("X")==1?"X":"Y"); std::string all{"ABXY"}; for(char ch: all) if(s[0]!=ch) c.push_back(ch); while(s.size()<n-1){ int k=s.size(); int cur=press(make(s)); if(cur==k) s.push_back(c[2]); else if(cur==k+1) s.push_back(c[1]); else s.push_back(c[0]); } if(s.size()==n-1){ std::string curs=s; curs.push_back(c[0]); curs+=s; curs.push_back(c[1]); if(press(curs)==n-1) s.push_back(c[2]); else{ curs=s; curs.push_back(c[0]); if(press(curs)==n) s.push_back(c[0]) else s.push_back(c[1]); } } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:16: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |  while(s.size()<n-1){
      |        ~~~~~~~~^~~~
combo.cpp:39:13: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   39 |  if(s.size()==n-1){
      |     ~~~~~~~~^~~~~
combo.cpp:50:22: error: expected ';' before 'else'
   50 |     s.push_back(c[0])
      |                      ^
      |                      ;
   51 |    else
      |    ~~~~