제출 #1043790

#제출 시각아이디문제언어결과실행 시간메모리
1043790sofpp콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h>

using namespace std;


string guess_sequence(int N) {
  string p = ""; string S = "";
  n = N;
  if(press("AB")>=1){
    if(press("A")==1){
      p+="A";
    }
    else{
      p+="B";
    }
  }
  else{
    if(press("X")>=1){
      p+="X";
    }
    else{
      p+="Y";
    }
  }


  vector<string> a;
  if(p!="A")a.push_back("A");
  if(p!="B")a.push_back("B");
  if(p!="X")a.push_back("X");
  if(p!="Y")a.push_back("Y");

  for(int i=1;i<N-1;i++){
    string temp="";
    temp+=(p+a[0]+p+a[1]+a[0]+p+a[1]+a[1]+p+a[1]+a[2]);
    int res = press(temp); 
    if(res==1+p.size()){
      p+=a[0];
    }
    else if(res==2+p.size()){
      p+=a[1];
    }else{
      p+=a[2];
    }
  }
  if(N>1){
    if(press(p+a[0]+p+a[1])>=1+p.size()){
      if(press(p+a[0])==1+p.size()){
        p+=a[0];
      }
      else{
        p+=a[1];
      }
    }
    else{
      p+=a[2];
    }
  }
  return p;
}



int main(){


  cout<<guess_sequence(7);

  return 0;
}
  

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:8:3: error: 'n' was not declared in this scope
    8 |   n = N;
      |   ^
combo.cpp:9:6: error: 'press' was not declared in this scope
    9 |   if(press("AB")>=1){
      |      ^~~~~
combo.cpp:36:15: error: 'press' was not declared in this scope; did you mean 'res'?
   36 |     int res = press(temp);
      |               ^~~~~
      |               res
combo.cpp:37:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     if(res==1+p.size()){
      |        ~~~^~~~~~~~~~~~
combo.cpp:40:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |     else if(res==2+p.size()){
      |             ~~~^~~~~~~~~~~~
combo.cpp:47:8: error: 'press' was not declared in this scope
   47 |     if(press(p+a[0]+p+a[1])>=1+p.size()){
      |        ^~~~~