Submission #843122

#TimeUsernameProblemLanguageResultExecution timeMemory
843122ogkostyaRobot Contest (IOI23_robot)C++17
16 / 100
98 ms6260 KiB
#include "robot.h"

static const int MAX_COLOR = 19;
static const int MAX_STATE = 5153632;
bool program[MAX_STATE];

int e(const std::vector<int>& S)
{
    int state = 0;
    for (int s : S)
    {
        state = (MAX_COLOR + 3) * state + s + 2;
    }
    return state;
}

void a1(std::vector<int> S, int Z, char A)
{
    int s = e(S);
    if (!program[s])
    {
        program[s] = true;
        set_instruction(S, Z, A);
    }
    else
    {
        int p = 1;
        p = 2;
    }
}

void a(int p, std::vector<int> W, std::vector<int> S, std::vector<int> E, std::vector<int> N, int Z, char A)
{
    for (auto w : W)
        for (auto s : S)
            for (auto e : E)
                for (auto n : N)
                    a1({ p, w, s, e, n }, Z, A);
}

void program_pulibot()
{
    // find
    a(0, { -2, -1, 2, 0, 4 }, { -2, -1, 2, 0, 4 }, { 0 }, { -2, -1, 2, 0, 4 }, 2, 'E');
    a(0, { -2, -1, 2, 0, 4 }, { 0 }, { -2, -1, 2, 4 }, { -2, -1, 2, 0, 4 }, 2, 'S');
    a(0, { -1, 2, 0, 4 }, { -2, -1, 2, 4 }, { -1, 2, 4 }, { 0 }, 2, 'N');
    a(0, { 0 }, { -1, 4, 2 }, { -2, -1, 4, 2 }, { -1, 4, 2 }, 2, 'W');

    a(2, { -2, -1, 2, 0, 4 }, { -2, -1, 2, 0, 4 }, { 0 }, { -2, -1, 2, 0, 4 }, 2, 'E');
    a(2, { -2, -1, 2, 0, 4 }, { 0 }, { -2, -1, 2, 4 }, { -2, -1, 2, 0, 4 }, 2, 'S');
    a(2, { -1, 2, 0, 4 }, { -2, -1, 2, 4 }, { -1, 2, 4 }, { 0 }, 2, 'N');
    a(2, { 0 }, { -1, 4, 2 }, { -2, -1, 4, 2 }, { -1, 4, 2 }, 2, 'W');

    // back
    a(0, { -1, 2, 0 }, { -2 }, { -2 }, { -1, 2, 0 }, 1, 'H');

    //deadlock
    a(0, { -2, -1, 2, 4 }, { -2, -1, 2, 4 }, { -2, -1, 2, 4 }, { -2, -1, 2, 4 }, 4, 'H');
    a(2, { -2, -1, 2, 4 }, { -2, -1, 2, 4 }, { -2, -1, 2, 4 }, { -2, -1, 2, 4 }, 5, 'H');

    a(5, { 4 }, { -2, -1, 0, 2, 4 }, { -2, -1, 0, 2, 4 }, { -2, -1, 0, 2, 4 }, 5, 'W');
    a(5, { -2, -1, 0, 2 }, { 4 }, { -2, -1, 0, 2, 4 }, { -2, -1, 0, 2, 4 }, 5, 'S');
    a(5, { -2, -1, 0, 2 }, { -2, -1, 0, 2 }, { 4 }, { -2, -1, 0, 2, 4 }, 5, 'E');
    a(5, { -2, -1, 0, 2 }, { -2, -1, 0, 2 }, { -2, -1, 0, 2 }, { 4 }, 5, 'N');

    a(5, { -2, -1, 0, 2 }, { -2, -1, 0, 2 }, { -2, -1, 0, 2 }, { -2, -1, 0, 2 }, 4, 'H');

    a(4, { 5 }, { -2, -1, 0, 4 }, { -2, -1, 0, 4 }, { -2, -1, 0, 4 }, 0, 'W');
    a(4, { -2, -1, 0, 4 }, { 5 }, { -2, -1, 0, 4 }, { -2, -1, 0, 4 }, 0, 'S');
    a(4, { -2, -1, 0, 4 }, { -2, -1, 0, 4 }, { 5 }, { -2, -1, 0, 4 }, 0, 'E');
    a(4, { -2, -1, 0, 4 }, { -2, -1, 0, 4 }, { -2, -1, 0, 4 }, { 5 }, 0, 'N');

    a(4, { 2 }, { -2, -1, 0 }, { -2, -1, 0 }, { -2, -1, 0 }, 4, 'W');
    a(4, { -2, -1, 0 }, { 2 }, { -2, -1, 0 }, { -2, -1, 0 }, 4, 'S');
    a(4, { -2, -1, 0 }, { -2, -1, 0 }, { 2 }, { -2, -1, 0 }, 4, 'E');
    a(4, { -2, -1, 0 }, { -2, -1, 0 }, { -2, -1, 0 }, { 2 }, 4, 'N');


    // back continue
    a(2, { 1 }, { -2, -1, 0, 2, 4 }, { -2, -1, 0, 2, 4 }, { -2, -1, 0, 2, 4 }, 1, 'H');
    a(2, { -2, -1, 0, 2, 4 }, { 1 }, { -2, -1, 0, 2, 4 }, { -2, -1, 0, 2, 4 }, 1, 'H');
    a(2, { -2, -1, 0, 2, 4 }, { -2, -1, 0, 2, 4 }, { 1 }, { -2, -1, 0, 2, 4 }, 1, 'H');
    a(2, { -2, -1, 0, 2, 4 }, { -2, -1, 0, 2, 4 }, { -2, -1, 0, 2, 4 }, { 1 }, 1, 'H');

    a(1, { 4 }, { -2, -1, 0, 1, 2, 4 }, { -2, -1, 0, 1, 2, 4 }, { -2, -1, 0, 1, 2, 4 }, 1, 'W');
    a(1, { -2, -1, 0, 1, 2 }, { 4 }, { -2, -1, 0, 1, 2, 4 }, { -2, -1, 0, 1, 2, 4 }, 1, 'S');
    a(1, { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, { 4 }, { -2, -1, 0, 1, 2, 4 }, 1, 'E');
    a(1, { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, { -2, -1, 0, 1, 2 }, { 4 }, 1, 'N');

    a(4, { 1 }, { -2, -1, 0, 1, 4 }, { -2, -1, 0, 1, 4 }, { -2, -1, 0, 1, 4 }, 0, 'W');
    a(4, { -2, -1, 0, 4 }, { 1 }, { -2, -1, 0, 1, 4 }, { -2, -1, 0, 1, 4 }, 0, 'S');
    a(4, { -2, -1, 0, 4 }, { -2, -1, 0, 4 }, { 1 }, { -2, -1, 0, 1, 4 }, 0, 'E');
    a(4, { -2, -1, 0, 4 }, { -2, -1, 0, 4 }, { -2, -1, 0, 4 }, { 1 }, 0, 'N');

    a(1, { 2 }, { -2, -1, 0, 1 }, { -2, -1, 0, 1 }, { -2, -1, 0, 1 }, 1, 'W');
    a(1, { -2, -1, 0, 1 }, { 2 }, { -2, -1, 0, 1 }, { -2, -1, 0, 1 }, 1, 'S');
    a(1, { -2, -1, 0, 1 }, { -2, -1, 0, 1 }, { 2 }, { -2, -1, 0, 1 }, 1, 'E');
    a(1, { -2, -1, 0, 1 }, { -2, -1, 0, 1 }, { -2, -1, 0, 1 }, { 2 }, 1, 'N');

    // fin
    a(1, { -2 }, { -1, 1, 0 }, { -1, 1, 0 }, { -2 }, 1, 'T');
}

Compilation message (stderr)

robot.cpp: In function 'void a1(std::vector<int>, int, char)':
robot.cpp:27:13: warning: variable 'p' set but not used [-Wunused-but-set-variable]
   27 |         int p = 1;
      |             ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...