Submission #1335372

#TimeUsernameProblemLanguageResultExecution timeMemory
1335372NValchanovRobot Contest (IOI23_robot)C++20
Compilation error
0 ms0 KiB
#include "robot.h"
#include <vector>

using namespace std;

pair < int, int > get_interval(int x)
{
    if(x == -3)
        return {-2, 1};

    return {x, x};
}

void set_interval(vector < int > s, int col, char dir)
{
    for(int c = get_interval(s[0]).first; c <= get_interval(s[0]).second; c++)
    {
        for(int w = get_interval(s[1]).first; w <= get_interval(s[1]).second; w++)
        {
            for(int s = get_interval(s[2]).first; s <= get_interval(s[2]).second; s++)
            {
                for(int e = get_interval(s[3]).first; e <= get_interval(s[3]).second; e++)
                {
                    for(int n = get_interval(s[4]).first; n <= get_interval(s[4]).second; n++)
                    {
                        set_instruction({c, w, s, e, n}, col, dir);
                    }
                }
            }
        }
    }
}

void program_pulibot()
{
    set_interval({-3, -3, 0, -3}, 1, 'E');
    set_interval({-3, -2, -1, -3}, 1, 'N');
    set_interval({-3, -2, -2, -3}, 1, 'T');
    set_interval({-3, -3, -1, -2}, 1, 'S');
    set_interval({-3, 0, -2, -3}, 1, 'S');
}

Compilation message (stderr)

robot.cpp: In function 'void set_interval(std::vector<int>, int, char)':
robot.cpp:20:39: error: invalid types 'int[int]' for array subscript
   20 |             for(int s = get_interval(s[2]).first; s <= get_interval(s[2]).second; s++)
      |                                       ^
robot.cpp:20:70: error: invalid types 'int[int]' for array subscript
   20 |             for(int s = get_interval(s[2]).first; s <= get_interval(s[2]).second; s++)
      |                                                                      ^
robot.cpp:22:43: error: invalid types 'int[int]' for array subscript
   22 |                 for(int e = get_interval(s[3]).first; e <= get_interval(s[3]).second; e++)
      |                                           ^
robot.cpp:22:74: error: invalid types 'int[int]' for array subscript
   22 |                 for(int e = get_interval(s[3]).first; e <= get_interval(s[3]).second; e++)
      |                                                                          ^
robot.cpp:24:47: error: invalid types 'int[int]' for array subscript
   24 |                     for(int n = get_interval(s[4]).first; n <= get_interval(s[4]).second; n++)
      |                                               ^
robot.cpp:24:78: error: invalid types 'int[int]' for array subscript
   24 |                     for(int n = get_interval(s[4]).first; n <= get_interval(s[4]).second; n++)
      |                                                                              ^