제출 #534524

#제출 시각아이디문제언어결과실행 시간메모리
534524Abdulmohsen1284콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include "combo.h"

std::string guess_sequence(int N) {
    string g,s;
    g="AB";
    long long ans=press(g);
    if(ans==1)
    {
        g="A";
        ans=press(g);
        if(ans==1)
            s="A";
        else
            s="B";
    }
    else
    {
        g="X";
        ans=press(g);
        if(ans==1)
            s="X";
        else
            s="Y";
    }
    char a[4];
    long long cur=0;
    string chek="ABXY";
    for(int i=0;i<chek.size();i++)
    {
        if(s[0]!=chek[i])
        {
            a[cur]=chek[i];
            cur++;
        }
    }
    for(int i=1;i<N-1;i++)
    {
        string rn;
        rn=s+chek[0];
        for(int j=0;j<3;j++)
            rn+=s+check[1]+chek[j];
        ans=press(rn);
        if(ans==s.size())
        {
            s+=chek[2];
        }
        if(ans==s.size()+1)
        {
            s+=chek[0];
        }
        if(ans==s.size()+2)
        {
            s+=chek[1];
        }
    }
    if(N!=1)
    {
        string rn=s+"A"+s+"B";
        ans=press(rn);
        if(ans==s.size()+1)
        {
            rn=s+"A";
            ans=press(rn);
            if(ans==s.size()+1)
                s+="A";
            else
                s+="B";
        }
        else
        {
            rn=s+"X";
            ans=press(rn);
            if(ans==s.size()+1)
                s+="X";
            else
                s+="Y";
        }
    }
    return s;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:4:5: error: 'string' was not declared in this scope; did you mean 'std::string'?
    4 |     string g,s;
      |     ^~~~~~
      |     std::string
In file included from /usr/include/c++/10/string:39,
                 from combo.h:3,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stringfwd.h:79:33: note: 'std::string' declared here
   79 |   typedef basic_string<char>    string;
      |                                 ^~~~~~
combo.cpp:5:5: error: 'g' was not declared in this scope
    5 |     g="AB";
      |     ^
combo.cpp:12:13: error: 's' was not declared in this scope
   12 |             s="A";
      |             ^
combo.cpp:14:13: error: 's' was not declared in this scope
   14 |             s="B";
      |             ^
combo.cpp:21:13: error: 's' was not declared in this scope
   21 |             s="X";
      |             ^
combo.cpp:23:13: error: 's' was not declared in this scope
   23 |             s="Y";
      |             ^
combo.cpp:27:11: error: expected ';' before 'chek'
   27 |     string chek="ABXY";
      |           ^~~~~
      |           ;
combo.cpp:28:19: error: 'chek' was not declared in this scope
   28 |     for(int i=0;i<chek.size();i++)
      |                   ^~~~
combo.cpp:30:12: error: 's' was not declared in this scope
   30 |         if(s[0]!=chek[i])
      |            ^
combo.cpp:38:15: error: expected ';' before 'rn'
   38 |         string rn;
      |               ^~~
      |               ;
combo.cpp:39:9: error: 'rn' was not declared in this scope
   39 |         rn=s+chek[0];
      |         ^~
combo.cpp:39:12: error: 's' was not declared in this scope
   39 |         rn=s+chek[0];
      |            ^
combo.cpp:39:14: error: 'chek' was not declared in this scope
   39 |         rn=s+chek[0];
      |              ^~~~
combo.cpp:41:19: error: 'check' was not declared in this scope
   41 |             rn+=s+check[1]+chek[j];
      |                   ^~~~~
combo.cpp:58:15: error: expected ';' before 'rn'
   58 |         string rn=s+"A"+s+"B";
      |               ^~~
      |               ;
combo.cpp:59:19: error: 'rn' was not declared in this scope
   59 |         ans=press(rn);
      |                   ^~
combo.cpp:60:17: error: 's' was not declared in this scope
   60 |         if(ans==s.size()+1)
      |                 ^
combo.cpp:79:12: error: 's' was not declared in this scope
   79 |     return s;
      |            ^