Submission #852851

#TimeUsernameProblemLanguageResultExecution timeMemory
852851dranjohn로봇 대회 (IOI23_robot)C++17
0 / 100
92 ms6100 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 (self != 1 && right == -2 && down == -2) return { 'H', 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
    if (right == 4) return { 'E', self == 1 ? 1 : 0 };
    if (down == 5) return { 'S', self == 1 ? 1 : 0 };
    if (left == 2) return { 'W', self == 1 ? 1 : 0 };
    if (up == 3) return { 'N', self == 1 ? 1 : 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...