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 <bits/stdc++.h>
using namespace std;
#include "robot.h"
enum State {
BOUNDARY = -2,
OBSTACLE = -1,
EMPTY = 0,
MAIN = 1,
WEST = 2,
SOUTH = 3,
EAST = 4,
NORTH = 5,
EVERYTHING = -42,
BLOCKED = -3,
};
enum Move {
M_STAY = 'H',
M_WEST = 'W',
M_SOUTH = 'S',
M_EAST = 'E',
M_NORTH = 'N',
M_TERMINATE = 'T',
};
namespace Script {
static const int arrLen = 5;
using StateArray = array<State, arrLen>;
using Instruction = pair<State, Move>;
map<StateArray, Instruction> mp;
// Helper functions
vector<State> group(State S){
if (S == BLOCKED) return {BOUNDARY, OBSTACLE};
if (S == EVERYTHING) return {
BOUNDARY, OBSTACLE, EMPTY, MAIN,
WEST, SOUTH, EAST, NORTH
};
return {S};
}
template <bool OVERWRITE = false>
void program(StateArray S, Instruction I){
vector<StateArray> arrs = {StateArray()};
// Construct all possible StateArray(s)
for (int i = 0; i < arrLen; i++){
vector<StateArray> new_arrs;
vector<State> repr = group(S[i]);
for (auto arr: arrs){
for (auto j: repr){
new_arrs.push_back(arr);
new_arrs.back()[i] = j;
}
}
new_arrs.swap(arrs);
}
// Resolve
for (auto arr: arrs){
if (!OVERWRITE && mp.count(arr)) continue;
mp[arr] = I;
}
}
template <bool OVERWRITE = false>
void program(StateArray S, State Z, Move A){
return program<OVERWRITE>(S, {Z, A});
}
void set_all_instruction(){
for (auto [S, I]: mp){
vector<int> vS(begin(S), begin(S) + arrLen);
set_instruction(vS, I.first, I.second);
}
}
}
void program_pulibot(){
Script::program<false>({
EVERYTHING, EVERYTHING, EVERYTHING, EMPTY, EVERYTHING
},
MAIN,
M_EAST);
Script::program<false>({
EVERYTHING, EVERYTHING, EMPTY, EVERYTHING, EVERYTHING
},
MAIN,
M_SOUTH);
Script::program<true>({
EVERYTHING, EVERYTHING, BOUNDARY, BOUNDARY, EVERYTHING
},
MAIN,
M_TERMINATE);
Script::set_all_instruction();
}
# | 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... |