제출 #852853

#제출 시각아이디문제언어결과실행 시간메모리
852853dranjohn로봇 대회 (IOI23_robot)C++17
34 / 100
105 ms6280 KiB
#include "robot.h"
#include <bits/stdc++.h>
using namespace std;
// https://oj.uz/problem/view/IOI23_robot

pair<char, int> dir(int self, int left, int down, int right, int up) {
    // done
    if (right == -2 && down == -2) return { up == 3 ? 'N' : 'W', 1 };
    if ((right == 1 || down == 1) && left == -2 && up == -2) return { 'T', 1 };

    // finalize solution
    if (left == 1 || down == 1 || right == 1 || up == 1) {
        if (right > 1) return { 'E', 1 };
        if (down > 1) return { 'S', 1 };
        if (left > 1) return { 'W', 1 };
        if (up > 1) return { 'N', 1 };
    }

    // search deeper
    if (right == 0 && self < 2) return { 'E', 2 };
    if (down == 0 && self < 3) return { 'S', 3 };
    if (left == 0 && self < 4) return { 'W', 4 };
    if (up == 0 && self < 5) return { 'N', 5 };

    // backtrack from dead end
    if (right == 4) return { 'E', 0 };
    if (down == 5) return { 'S', 0 };
    if (left == 2) return { 'W', 0 };
    if (up == 3) return { 'N', 0 };

    // unknown state
    return { 'T', 0 };
}

void program_pulibot() {
    vector<int> states;
    for (int i = -2; i <= 5; ++i) states.push_back(i);

    for (int l : states)
    for (int d : states)
    for (int r : states)
    for (int u : states)
    for (int s : states) {
        char nd;
        int ns;
        tie(nd, ns) = dir(s, l, d, r, u);

        set_instruction({ s, l, d, r, u }, ns, nd);
    }
}
#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...