This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |