제출 #908316

#제출 시각아이디문제언어결과실행 시간메모리
908316dragusanu_rares콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> using namespace std; string guess_sequence(int n){ if(n==1){ if(press("X")==1)return "X"; else if(press("Y")==1)return "Y"; else if(press("A")==1)return "A"; else return "B"; } else{ char ch1,a,b,c; string cunoscut; if(press("XY")>=1){ if(press("X")==1)ch1='X'; else ch1='Y'; } else{ if(press("A")==1)ch1='A'; else ch1='B'; } cunoscut=ch1; if(ch1=='A'){ a='B'; b='X'; c='Y'; } else if(ch1=='B'){ a='A'; b='X'; c='Y'; } else if(ch1=='X'){ a='A'; b='B'; c='Y'; } else{ a='A'; b='B'; c='X'; } while(cunoscut.size()<n-1){ string guess=cunoscut+b+cunoscut+c+a+cunoscut+c+b+cunoscut+c+c; int x=press(guess)-cunoscut.size(); if(x==0)cunoscut.push_back(a); else if(x==1)cunoscut.push_back(b); else cunoscut.push_back(c); } if(press(cunoscut+a)==n)return cunoscut+a; else if(press(cunoscut+b)==n)return cunoscut+b; else return cunoscut+c; } } int main(){ return 0; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:5:12: error: 'press' was not declared in this scope
    5 |         if(press("X")==1)return "X";
      |            ^~~~~
combo.cpp:13:12: error: 'press' was not declared in this scope
   13 |         if(press("XY")>=1){
      |            ^~~~~
combo.cpp:42:30: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   42 |         while(cunoscut.size()<n-1){
      |               ~~~~~~~~~~~~~~~^~~~
combo.cpp:44:19: error: 'press' was not declared in this scope
   44 |             int x=press(guess)-cunoscut.size();
      |                   ^~~~~
combo.cpp:49:12: error: 'press' was not declared in this scope
   49 |         if(press(cunoscut+a)==n)return cunoscut+a;
      |            ^~~~~
combo.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
   53 | }
      | ^