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 <vector>
using namespace std;
char get_dir(int color, int east, int west, int north, int south){
char dir = 'H';
if(east == color)dir = 'E';
if(west == color)dir = 'W';
if(north == color)dir = 'N';
if(south == color)dir = 'S';
return dir;
}
void set_from_states(int curr, int west, int south, int east, int north){
vector<int> states{curr, west, south, east, north};
if(east == -2 && south == -2){
if(curr == 0){
char dir = get_dir(1, east, west, north, south);
set_instruction(states, 3, dir);
return;
}
set_instruction(states, 1, 'T');
return;
}
if(curr == 2){
char dir = get_dir(2, east, west, north, south);
if(dir != 'H'){
set_instruction(states, 4, dir);
return;
}
dir = get_dir(4, east, west, north, south);
set_instruction(states, 0, dir);
return;
}
if(curr == 4){
char dir = get_dir(3, east, west, north, south);
if(dir != 'H'){
set_instruction(states, 0, dir);
return;
}
dir = get_dir(4, east, west, north, south);
set_instruction(states, 0, dir);
return;
}
if(curr == 0){
char dir = get_dir(0, east, west, north, south);
if(dir != 'H'){
set_instruction(states, 1, dir);
return;
}
dir = get_dir(1, east, west, north, south);
set_instruction(states, 2, dir);
return;
}
if(curr == 1){
int count_3 = 0;
count_3 += east == 3;
count_3 += west == 3;
count_3 += north == 3;
count_3 += south == 3;
if(count_3){
char dir = get_dir(2, east, west, north, south);
if(dir != 'H'){
set_instruction(states, 3, dir);
return;
}
dir = get_dir(1, east, west, north, south);
if(dir != 'H'){
set_instruction(states, 3, dir);
}
else{
set_instruction(states, 3, 'H');
}
return;
}
char dir = get_dir(0, east, west, north, south);
if(dir != 'H'){
set_instruction(states, 1, dir);
return;
}
dir = get_dir(1, east, west, north, south);
set_instruction(states, 2, dir);
return;
}
if(curr == 3){
char dir = get_dir(3, east, west, north, south);
set_instruction(states, 1, dir);
return;
}
}
void program_pulibot()
{
for(int curr = 0; curr <= 4; ++curr){
for(int east = -2; east <= 4; ++east){
for(int south = -2; south <= 4; ++south){
for(int north = -2; north <= 4; ++north){
for(int west = -2; west <= 4; ++west){
set_from_states(curr, west, south, east, north);
}
}
}
}
}
}
# | 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... |