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;
#define arr array
#define vec vector
#define si set_instruction
// east, south, west, north
pair<char, int> get_action(arr<int, 5> state) {
map<int, char> dir;
dir[1] = 'E';
dir[2] = 'S';
dir[3] = 'W';
dir[4] = 'N';
dir[-1] = 'T';
arr<int, 5> focc{-1, -1, -1, -1, -1};
for(int j = 0; j<5; j++) {
for(int i = 1; i<5; i++) {
if(state[i] == j) {
focc[j] = i;
break;
}
}
}
if(focc[1] != -1) {
if(state[3] == -2 && state[4] == -2) return {'T', 1};
// assert(focc[2] != -1);
return {dir[focc[2]], 1};
}
if(state[0] == 0 || state[0] == 2) {
if(state[1] == -2 && state[2] == -2) {
return {dir[focc[2]], 1};
}
if(focc[0] == -1) {
return {dir[focc[2]], 3};
}
return {dir[focc[0]], 2};
}
return {'T', 1};
}
// 1 - path
// 2 - processing
// 3 - visited
// 4 - cleaning up
void all_state(arr<int, 5> cur, int i) {
if(i==5) {
auto action = get_action(cur);
//cerr << action.second << ' ' << action.first << '\n';
set_instruction({cur[0], cur[3], cur[2], cur[1], cur[4]}, action.second, action.first);
return;
}
vec<int> pos{-2, -1, 0, 1, 2, 3, 4};
for(int val : pos) {
cur[i] = val;
all_state(cur, i+1);
}
}
// self, west, south, east, north
void program_pulibot()
{
all_state({0, 0, 0, 0, 0}, 0);
}
# | 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... |