Submission #1157596

#TimeUsernameProblemLanguageResultExecution timeMemory
1157596thieunguyenhuyRobot Contest (IOI23_robot)C++20
24 / 100
66 ms5960 KiB
#include "robot.h"

#include <bits/stdc++.h>
using namespace std;

#define POPCOUNT(n) (__builtin_popcountll((n)))
#define CLZ(n) (__builtin_clzll((n)))
#define CTZ(n) (__builtin_ctzll((n)))
#define LOG(n) (63 - __builtin_clzll((n)))
#define BIT(n, i) (((n) >> (i)) & 1ll)
#define MASK(i) (1ll << (i))
#define FLIP(n, i) ((n) ^ (1ll << (i)))
#define ON(n, i) ((n) | MASK(i))
#define OFF(n, i) ((n) & ~MASK(i))

#define Int __int128
#define fi first
#define se second

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<pair<int, int>> vii;
typedef vector<pair<long long, long long>> vll;
typedef vector<pair<long long, int>> vli;
typedef vector<pair<int, long long>> vil;

template <class T1, class T2> bool maximize(T1 &x, T2 y) {
    if (x < y) {
        x = y;
        return true;
    }
    return false;
}
template <class T1, class T2> bool minimize(T1 &x, T2 y) {
    if (x > y) {
        x = y;
        return true;
    }
    return false;
}

template <class T> void remove_duplicate(vector<T> &ve) {
    sort (ve.begin(), ve.end());
    ve.resize(unique(ve.begin(), ve.end()) - ve.begin());
}

mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());
template <class T1, class T2> T1 random(T1 l, T2 r) {
    return uniform_int_distribution<T1>(l, r)(rng);
}
template <class T> T random(T r) {
    return rng() % r;
}

const int N = 1e6 + 5;
const int MOD = 1e9 + 7;
const int inf = 1e9;
const long long INF = 1e18;

const int dir[] = {'H', 'W', 'S', 'E', 'N'};

const int NOT_VIS = -7;
const int NOT_WALL = -6;
const int VIS = -5;
const int NOT_FREE = -4;
const int ANY = -3;
const int WALL = -2;
const int TRAP = -1;
const int FREE = 0;

void backtrack(int index, vector<int> S, int Z, char A) {
    if (index == S.size()) {
        set_instruction(S, Z, A);
        return;
    }

    if (S[index] == VIS) {
        for (int i = 1; i <= 4; ++i) {
            S[index] = i;
            backtrack(index + 1, S, Z, A);
        }
    }
    else if (S[index] == ANY) {
        for (int i = -2; i <= 4; ++i) {
            S[index] = i;
            backtrack(index + 1, S, Z, A);
        }
    }
    else if (S[index] == NOT_FREE) {
        for (int i = -2; i <= 4; ++i) if (i != FREE) {
            S[index] = i;
            backtrack(index + 1, S, Z, A);
        }
    }
    else if (S[index] == NOT_WALL) {
        for (int i = -2; i <= 4; ++i) if (i != WALL) {
            S[index] = i;
            backtrack(index + 1, S, Z, A);
        }
    }
    else if (S[index] == NOT_VIS) {
        for (int i = -2; i <= 0; ++i) {
            S[index] = i;
            backtrack(index + 1, S, Z, A);
        }
    }
    else backtrack(index + 1, S, Z, A);
}

void add(vector<int> S, int Z, char A) {
    backtrack(0, S, Z, A);
}

void program_pulibot() {
    add({0, FREE, NOT_WALL, ANY, ANY}, 1, 'W');
    add({0, FREE, WALL, NOT_WALL, ANY}, 1, 'W');
    add({0, NOT_FREE, NOT_WALL, ANY, ANY}, 1, 'H');
    add({0, NOT_FREE, WALL, NOT_WALL, ANY}, 1, 'H');
    
    add({1, ANY, FREE, ANY, ANY}, 2, 'S');
    add({1, ANY, NOT_FREE, ANY, ANY}, 2, 'H');
    
    add({2, ANY, ANY, FREE, ANY}, 3, 'E');
    add({2, ANY, ANY, NOT_FREE, ANY}, 3, 'H');
    
    add({3, ANY, ANY, ANY, FREE}, 4, 'N');
    add({3, ANY, ANY, ANY, NOT_FREE}, 4, 'H');
    
    add({4, VIS, NOT_VIS, NOT_VIS, NOT_VIS}, 0, 'W');
    add({4, NOT_VIS, VIS, NOT_VIS, NOT_VIS}, 0, 'S');
    add({4, NOT_VIS, NOT_VIS, VIS, NOT_VIS}, 0, 'E');
    add({4, NOT_VIS, NOT_VIS, NOT_VIS, VIS}, 0, 'N');

    add({0, VIS, WALL, WALL, NOT_VIS}, 5, 'W');
    add({0, NOT_VIS, WALL, WALL, VIS}, 5, 'N');

    for (int five = 1; five <= 4; ++five) {
        for (int par = 1; par <= 4; ++par) if (par != five) {
            vector<int> S(5);
            S[0] = VIS, S[1] = S[2] = S[3] = S[4] = NOT_VIS;
            S[five] = 5, S[par] = VIS;
            add(S, 5, dir[par]);
        }
    }

    add({VIS, WALL, 5, NOT_VIS, WALL}, 5, 'H');
    add({VIS, WALL, NOT_VIS, 5, WALL}, 5, 'H');

    add({5, 5, ANY, ANY, ANY}, 1, 'W');
    add({5, ANY, 5, ANY, ANY}, 1, 'S');
    add({5, ANY, ANY, 5, ANY}, 1, 'E');
    add({5, ANY, ANY, ANY, 5}, 1, 'N');

    add({5, 1, WALL, WALL, NOT_VIS}, 1, 'T');
    add({5, NOT_VIS, WALL, WALL, 1}, 1, 'T');
}
#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...