제출 #98855

#제출 시각아이디문제언어결과실행 시간메모리
98855brcode콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <iostream>
#include <vector>
using namespace std;
string guess_sequence(int n){
    string s;
    s = "AB";
    if(press(s)){
        if(press("A")){
            s = "A";
        }else{
            s = "B";
        }
    }else{
        if(press("X")){
            s = "X";
        }else{
            s = "Y";
        }
    }
    vector<string> choices;
    if(s!="X"){
        choices.push_back("X");
    }
    if(s!="Y"){
        choices.push_back("Y");
    }
    if(s!="A"){
        choices.push_back("A");
    }
    if(s!="B"){
        choices.push_back("B");
    }
    while(s.length()<n){
        if(s.length() == n-1){
            if(press(s+choices[0]) == n){
                s+=choices[0];
                break;
            }else if(press(s+choices[1]) == n){
                s+=choices[1];
                break;
            }else{
                s+=choices[2];
                break;
            }
        }
        string q;
        q+= (s+choices[0]+choices[0]);
        q+= (s+choices[0]+choices[1]);
        q+=(s+choices[1]+choices[0]);
        int pressed = press(q);
        if(pressed == s.length()+2){
            string p = s+choices[0]+choices[0];
            int hold = press(p);
            if(hold == s.length()+2){
                s+=choices[0]+choices[0];
                continue;
            }else if(hold == s.length()+1){
                s+=choices[0]+choices[1];
                continue;
            }else{
                s+=choices[1]+choices[0];
                continue;
            }
        }else if(pressed == s.length() + 1){
            string p = s+choices[1]+choices[1];
            int hold = pressed(p);
            if(hold == s.length() + 2){
                s+=choices[1]+choices[1];
                continue;
            }else if(hold == s.length() + 1){
                s+=choices[1]+choices[2];
                continue;
            }else{
                s+=choices[0]+choices[2];
            }
        }else{
            s+=choices[2];
        }
    }
    return s;
    
}
int main() {
    int a, b;
    cin >> a >> b;
    cout << a + b;
    return 0;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:7:8: error: 'press' was not declared in this scope
    7 |     if(press(s)){
      |        ^~~~~
combo.cpp:33:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   33 |     while(s.length()<n){
      |           ~~~~~~~~~~^~
combo.cpp:34:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   34 |         if(s.length() == n-1){
      |            ~~~~~~~~~~~^~~~~~
combo.cpp:35:16: error: 'press' was not declared in this scope
   35 |             if(press(s+choices[0]) == n){
      |                ^~~~~
combo.cpp:50:23: error: 'press' was not declared in this scope; did you mean 'pressed'?
   50 |         int pressed = press(q);
      |                       ^~~~~
      |                       pressed
combo.cpp:51:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   51 |         if(pressed == s.length()+2){
      |            ~~~~~~~~^~~~~~~~~~~~~~~
combo.cpp:54:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |             if(hold == s.length()+2){
      |                ~~~~~^~~~~~~~~~~~~~~
combo.cpp:57:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |             }else if(hold == s.length()+1){
      |                      ~~~~~^~~~~~~~~~~~~~~
combo.cpp:64:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |         }else if(pressed == s.length() + 1){
      |                  ~~~~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:66:33: error: 'pressed' cannot be used as a function
   66 |             int hold = pressed(p);
      |                                 ^
combo.cpp:67:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |             if(hold == s.length() + 2){
      |                ~~~~~^~~~~~~~~~~~~~~~~
combo.cpp:70:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |             }else if(hold == s.length() + 1){
      |                      ~~~~~^~~~~~~~~~~~~~~~~