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;
// (2, west), (3, sout), (4, eatst), (5, north)
map<int, int> op = {
{2, 4},
{3, 5},
{4, 2},
{5, 3}
};
string dir = " WSEN";
void program_pulibot(){
auto findp = [&](auto state){
int curdir = 0;
for(int cur=1; cur<=4; cur++){
if(state[cur]==op[cur+1]){
curdir=cur+1;
}
}
return curdir;
};
auto findany = [&](auto state){
int curdir = 0;
for(int cur=1; cur<=4; cur++){
if(2<=state[cur] and state[cur]<=5){
curdir=cur+1;
}
}
return curdir;
};
for(int i1=0; i1<7; i1++){
for(int i2=-2; i2<7; i2++){
for(int i3=-2; i3<7; i3++){
for(int i4=-2; i4<7; i4++){
for(int i5=-2; i5<7; i5++){
vector<int> state = {i1, i2, i3, i4, i5};
int cnt1 = 0, cnt6 = 0, dir1 = 0, dir6 = 0;
for(int d=1; d<=4; d++){
if(state[d]==1){
cnt1++;
dir1=d+1;
}
if(state[d]==6){
cnt6++;
dir6=d+1;
}
}
if(cnt6){
if(state[1]==-2 and state[4]==-2){
if(findp(state))
set_instruction(state, 6, dir[findp(state)]);
else
set_instruction(state, 1, dir[dir6]);
}else if(cnt6==1){
if(findp(state)){
set_instruction(state, 6, dir[findp(state)]);
}else{
if(cnt1){
if(findany(state)){
set_instruction(state, 6, dir[findany(state)]);
}else{
set_instruction(state, 1, dir[dir6]);
}
}else{
set_instruction(state, 0, dir[dir6]);
}
}
}else if(cnt6==2){
if(2<=state[0] and state[0]<=5)
set_instruction(state, 0, dir[state[0]]);
}
}else if(cnt1){
if(findany(state)){
set_instruction(state, 6, dir[findany(state)]);
}else{
set_instruction(state, 1, 'T');
}
}else{
if(state[0]==0){
if(state[2]==-2 and state[3]==-2){
if(findp(state))
set_instruction(state, 6, dir[findp(state)]);
}else if(state[1]==-2 and state[4]==-2){
set_instruction(state, 2, 'H');
}else{
if(findp(state)){
set_instruction(state, findp(state), dir[findp(state)]);
}
}
}else{
//walk
int next = (state[0] - 2 + 1)%4 + 2;
if(state[next-1]==op[next] or state[next-1]==0){
set_instruction(state, next, dir[next]);
}else{
set_instruction(state, next, 'H');
}
}
}
// start
// no adjacent
// C5
// C6
}
}
}
}
}
}
Compilation message (stderr)
robot.cpp: In function 'void program_pulibot()':
robot.cpp:42:33: warning: variable 'dir1' set but not used [-Wunused-but-set-variable]
42 | int cnt1 = 0, cnt6 = 0, dir1 = 0, dir6 = 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... |