이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robot.h"
#include <bits/stdc++.h>
using namespace std;
// 0 = unvisited (white)
// 1 = final visit (yellow)
// 2 = blocked (red)
// 3 = temp. visit (blue)
int white = 0, yellow = 1, red = 2, blue = 3;
string dir = "WSEN";
int i, j, k, l, m;
char get_dir(int col){
int pos = -1;
if(j==col) pos=0;
else if(k==col) pos=1;
else if(l==col) pos=2;
else if(m==col) pos=3;
return dir[pos];
}
bool exists_neighbour(int col){
return j==col or k==col or l==col or m==col;
}
void program_pulibot()
{
for(i = 0; i <= 3; i++){
for(j = -2; j <= 3; j++){
for(k = -2; k <= 3; k++){
for(l = -2; l <= 3; l++){
for(m = -2; m <= 3; m++){
if(j==-2 and m==-2 and i==blue){
// starting location and color = blue
set_instruction({i,j,k,l,m},yellow,'T');
}
else if(k==-2 and l==-2){
// final location, start coloring with yellow
set_instruction({i,j,k,l,m},yellow,get_dir(blue));
}
else if(i==3 or exists_neighbour(yellow)){
// if yellow somewhere, we are in the final phase
if(exists_neighbour(red)){
// firstly if there's red cell, go there while marking here as yellow
set_instruction({i,j,k,l,m},yellow,get_dir(red));
}
else if(exists_neighbour(blue)){
// if no red cell, but there are blue cells, go there
set_instruction({i,j,k,l,m},yellow,get_dir(blue));
}
else{
// if we are in a blocked place already, clear it, traverse back
set_instruction({i,j,k,l,m},white,get_dir(yellow));
}
}
else if(exists_neighbour(white)){
// if still in the exploration phase and we can explore:
// go to the next unvisited position, randomly
set_instruction({i,j,k,l,m},blue,get_dir(white));
}
else if(exists_neighbour(blue)){
// no where to go, mark as blocked, backtrack
set_instruction({i,j,k,l,m},red,get_dir(blue));
}
}
}
}
}
}
}
# | 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... |