제출 #281997

#제출 시각아이디문제언어결과실행 시간메모리
281997ec1117콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define mp make_pair

string guess_sequence(int N){
    string cur;//default?
    int x=press("AB");
    if(x==1 || 2){
        if(press("A")==1) cur="A";
        else cur="B";
    }
    else{
        if(press("X")==1)cur="X";
        else cur="Y";
    }
    set<string> set={"A","B","X","Y"};
    set.erase(cur);
    while(cur.length()<N){
        if(cur.length()==N-1){
            if(press(cur+*next(set.begin(),1))==N){
                return cur+*next(set.begin(),1);
            }
            else if(press(cur+*next(set.begin(),2))==N){
                return cur+*next(set.begin(),2);
            }
            else{
                return cur+*next(set.begin(),3);
            }
        }
        else{
            string tmp=cur+*next(set.begin(),1)+*next(set.begin(),1)+cur+*next(set.begin(),1)+*next(set.begin(),2)+cur+*next(set.begin(),1)+*next(set.begin(),3)+cur+*next(set.begin(),2);
            int x=press(tmp);
            if((int)x==cur.length()+2){
                cur+=*next(set.begin(),1);
            }
            else if(x==cur.length()+1){
                cur+=*next(set.begin(),2);
            }
            else{
                cur+=*next(set.begin(),3);
            }
        }
    }
}




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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:11: error: 'press' was not declared in this scope
    9 |     int x=press("AB");
      |           ^~~~~
combo.cpp:20:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   20 |     while(cur.length()<N){
      |           ~~~~~~~~~~~~^~
combo.cpp:21:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   21 |         if(cur.length()==N-1){
      |            ~~~~~~~~~~~~^~~~~
combo.cpp:35:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |             if((int)x==cur.length()+2){
      |                ~~~~~~^~~~~~~~~~~~~~~~
combo.cpp:38:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |             else if(x==cur.length()+1){
      |                     ~^~~~~~~~~~~~~~~~
combo.cpp:8:12: warning: control reaches end of non-void function [-Wreturn-type]
    8 |     string cur;//default?
      |            ^~~