제출 #95735

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

string guess_sequence(int N) {
    string ans = "";
    int a=press("A"),b=press("B"),c=press("X");
    unordered_set<char> poss {'A','B','X','Y'};
    if(a){
        ans+="A";
        poss.erase('A');
    }else if(b){
        ans+="B";
        poss.erase('B');
    }else if(c){
        ans+="X";
        poss.erase('X');
    }else{
        ans+="Y";
        poss.erase('Y');
    }
   // printf("%d\n",poss.size());
    for(int x=1;x<N-2;x++){
        int temp=0;
        string qu = "";
        auto it = poss.begin();
        qu+=ans + *it;

        for(char c:poss){
            qu+=ans+*next(it)+c;
        }
        //printf("%c %c %c\n",*next(it),*it,*next(next(it)));
        //printf("%s\n",qu.c_str());
        int coins=press(qu);

        //printf("%s %d %d\n",qu.c_str(),coins,(int)ans.size());
       // if(x==2)
          //  return 0;
        if(coins==(int)ans.size())
            ans+=*next(next(it));
        else if(coins==2+(int)ans.size()){
            ans+=*next(it);
        }else
            ans+=*it;

    }
    a=press(ans+*poss.begin()),b=press(ans+*next(poss.begin()));
    if(a==N-1)
        ans+=*poss.begin();
    else if(b==N-1)
        ans+=*next(poss.begin());
    else
        ans+=*next(next(poss.begin()));
    a=press(ans+*poss.begin()),b=press(ans+*next(poss.begin()));
    if(a==N)
        ans+=*poss.begin();
    else if(b==N)
        ans+=*next(poss.begin());
    else
        ans+=*next(next(poss.begin()));
    //cout<<ans;
    return ans;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:6:11: error: 'press' was not declared in this scope
    6 |     int a=press("A"),b=press("B"),c=press("X");
      |           ^~~~~
combo.cpp:11:14: error: 'b' was not declared in this scope
   11 |     }else if(b){
      |              ^
combo.cpp:14:14: error: 'c' was not declared in this scope
   14 |     }else if(c){
      |              ^
combo.cpp:23:13: warning: unused variable 'temp' [-Wunused-variable]
   23 |         int temp=0;
      |             ^~~~
combo.cpp:46:32: error: 'b' was not declared in this scope
   46 |     a=press(ans+*poss.begin()),b=press(ans+*next(poss.begin()));
      |                                ^