Submission #1270132

#TimeUsernameProblemLanguageResultExecution timeMemory
1270132truongdz_top12Robot Contest (IOI23_robot)C++20
Compilation error
0 ms0 KiB
#include "robot.h"
#include<bits/stdc++.h>
using namespace std;
const string dir="HWSEN";
const int nothing=-4;
const int boundary=-3;
const int obstacle=-2;
const int blank=-1;
const int path=0;
const int west=1;
const int south=2;
const int east=3;
const int north=4
int pos=0;
pair<int,int>make_move(int d){
    return {dir[d],d};
}
int prv(int d){
    return (d+1)%4+1;
}
int nxt(int d){
    return d%4+1;
}
pair<int,char>get(vector<int>S){
    for(int i=0;i<5;++i)
        --S[i];
    bool Start=(S[west]==boundary&&S[north]==boundary);
    bool End=(S[east]==boundary&&S[south]==boundary);
    if(S[pos]==blank){
        if(Start){
            if(S[south]==blank)
                return make_move(south);
            if(S[east]==blank)
                return make_move(east);
            return {'-',nothing};
        }
        if(End)
            return {'H',east};
        for(int nd=1;nd<5;++nd)
            if(S[nd]==prv(nd))
                return make_move(nd);
        return {'-',nothing};
    }
    if(S[pos]<=path)
        return {'-',nothing};
    if(S[pos]==prv(S[pos])){
        int nd=nxt(S[pos]);
        while(S[nd]!=blank&&S[nd]!=prv(nd))
            nd=nxt(nd);
        return make_move(nd);
    }
    for(int nd=1;nd<5;++nd)
        if(S[nd]==prv(nd))
            return {dir[nd],S[pos]};
    if(Start||count(S.begin(),S.end(),path)>0){
        if(End)
            return {'T',path};
        else
            return {dir[S[pos]],path};
    }
    return {dir[S[pos]],blank};
}
void program_pulibot(){
    vector<int>S(5);
    for(S[0]=-2;S[0]<=5;++S[0])
        for(S[1]=-2;S[1]<=5;++S[1])
            for(S[2]=-2;S[2]<=5;++S[2])
                for(S[3]=-2;S[3]<=5;++S[3])
                    for(S[4]=-2;S[4]<=5;++S[4]){
                        auto[A,Z]=get(S);
                            if(Z!=-4)
                                set_instruction(S,Z+1,A);
    }
}

Compilation message (stderr)

robot.cpp:14:1: error: expected ',' or ';' before 'int'
   14 | int pos=0;
      | ^~~
robot.cpp: In function 'std::pair<int, char> get(std::vector<int>)':
robot.cpp:29:10: error: 'pos' was not declared in this scope; did you mean 'pow'?
   29 |     if(S[pos]==blank){
      |          ^~~
      |          pow
robot.cpp:44:10: error: 'pos' was not declared in this scope; did you mean 'pow'?
   44 |     if(S[pos]<=path)
      |          ^~~
      |          pow
robot.cpp:46:10: error: 'pos' was not declared in this scope; did you mean 'pow'?
   46 |     if(S[pos]==prv(S[pos])){
      |          ^~~
      |          pow
robot.cpp:54:31: error: 'pos' was not declared in this scope; did you mean 'pow'?
   54 |             return {dir[nd],S[pos]};
      |                               ^~~
      |                               pow
robot.cpp:54:35: error: could not convert '{dir.std::__cxx11::basic_string<char>::operator[](((std::__cxx11::basic_string<char>::size_type)nd)), <expression error>}' from '<brace-enclosed initializer list>' to 'std::pair<int, char>'
   54 |             return {dir[nd],S[pos]};
      |                                   ^
      |                                   |
      |                                   <brace-enclosed initializer list>
robot.cpp:59:27: error: 'pos' was not declared in this scope; did you mean 'pow'?
   59 |             return {dir[S[pos]],path};
      |                           ^~~
      |                           pow
robot.cpp:59:37: error: could not convert '{<expression error>, path}' from '<brace-enclosed initializer list>' to 'std::pair<int, char>'
   59 |             return {dir[S[pos]],path};
      |                                     ^
      |                                     |
      |                                     <brace-enclosed initializer list>
robot.cpp:61:19: error: 'pos' was not declared in this scope; did you mean 'pow'?
   61 |     return {dir[S[pos]],blank};
      |                   ^~~
      |                   pow
robot.cpp:61:30: error: could not convert '{<expression error>, blank}' from '<brace-enclosed initializer list>' to 'std::pair<int, char>'
   61 |     return {dir[S[pos]],blank};
      |                              ^
      |                              |
      |                              <brace-enclosed initializer list>