제출 #853285

#제출 시각아이디문제언어결과실행 시간메모리
853285dranjohnRobot Contest (IOI23_robot)C++17
16 / 100
104 ms6484 KiB
#include "robot.h"
#include <bits/stdc++.h>
using namespace std;
// https://oj.uz/problem/view/IOI23_robot

constexpr int MAXS = 6;

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 (self != 0 && (left == 1 || down == 1 || right == 1 || up == 1)) {
        if (right == 4) return { 'E', 1 };
        if (down == 5) return { 'S', 1 };
        if (left == 2) return { 'W', 1 };
        if (up == 3) 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', 6 };
    if (up == 3) return { 'N', 6 };
    
    // unknown state
    return { 'T', 0 };
}

void program_pulibot() {
    vector<int> states;
    for (int i = -2; i <= MAXS; ++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...