제출 #1071117

#제출 시각아이디문제언어결과실행 시간메모리
1071117Faisal_Saqib로봇 대회 (IOI23_robot)C++17
컴파일 에러
0 ms0 KiB
#include "robot.h"
int op=10000;
void choose(int len,vector<int> pos,vector<int> taken)
{
    if(len==0)
    {
        if(taken[0]<0)return;
        int mx=100;
        char tp='?';
        string dir="FWSEN";;
        for(int i=1;i<taken.size();i++)
        {
            if(taken[i]>=0 and taken[i]<mx)
            {
                mx=taken[i];
                tp=dir[i];
            }
        }
        if(taken[2]==-2 and taken[3]==-2)
        {
            set_instruction(taken,1,'T');
        }
        else
        {
            if(tp!='?')
            {
                if((taken[0]+1)<=19)
                    set_instruction(taken,taken[0]+1,tp);           
            }
        }
        return;
    }
    for(auto i:pos)
    {
        taken.push_back(i);
        choose(len-1,pos,taken);
        taken.pop_back();
    }
}
void program_pulibot()
{

    vector<int> states = {-1,-2};
    for(int i=0;i<=19;i++)
        states.push_back(i);
    choose(5,states,{});
    // set_instruction({0, -2, -1, 0, -2}, 1, 'E');
    // set_instruction({0, 1, -1, 0, -2}, 1, 'E');
    // set_instruction({0, 1, 0, -2, -2}, 1, 'S');
    // set_instruction({0, -1, -2, -2, 1}, 1, 'T');
}

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

robot.cpp:3:21: error: 'vector' has not been declared
    3 | void choose(int len,vector<int> pos,vector<int> taken)
      |                     ^~~~~~
robot.cpp:3:27: error: expected ',' or '...' before '<' token
    3 | void choose(int len,vector<int> pos,vector<int> taken)
      |                           ^
robot.cpp: In function 'void choose(int, int)':
robot.cpp:7:12: error: 'taken' was not declared in this scope
    7 |         if(taken[0]<0)return;
      |            ^~~~~
robot.cpp:10:9: error: 'string' was not declared in this scope
   10 |         string dir="FWSEN";;
      |         ^~~~~~
robot.cpp:11:23: error: 'taken' was not declared in this scope
   11 |         for(int i=1;i<taken.size();i++)
      |                       ^~~~~
robot.cpp:16:20: error: 'dir' was not declared in this scope
   16 |                 tp=dir[i];
      |                    ^~~
robot.cpp:19:12: error: 'taken' was not declared in this scope
   19 |         if(taken[2]==-2 and taken[3]==-2)
      |            ^~~~~
robot.cpp:33:16: error: 'pos' was not declared in this scope
   33 |     for(auto i:pos)
      |                ^~~
robot.cpp:35:9: error: 'taken' was not declared in this scope
   35 |         taken.push_back(i);
      |         ^~~~~
robot.cpp: In function 'void program_pulibot()':
robot.cpp:43:5: error: 'vector' was not declared in this scope
   43 |     vector<int> states = {-1,-2};
      |     ^~~~~~
robot.cpp:43:5: note: suggested alternatives:
In file included from /usr/include/c++/10/vector:67,
                 from robot.h:1,
                 from robot.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from robot.h:1,
                 from robot.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
robot.cpp:43:12: error: expected primary-expression before 'int'
   43 |     vector<int> states = {-1,-2};
      |            ^~~
robot.cpp:45:9: error: 'states' was not declared in this scope; did you mean 'static'?
   45 |         states.push_back(i);
      |         ^~~~~~
      |         static
robot.cpp:46:14: error: 'states' was not declared in this scope; did you mean 'static'?
   46 |     choose(5,states,{});
      |              ^~~~~~
      |              static