# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
956418 | Dan4Life | 로봇 대회 (IOI23_robot) | C++17 | 0 ms | 0 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "robot.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define sz(a) (int)a.size()
#define all(a) begin(a),end(a)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
int boundary = -2, obstacle = -1, white = 0, yellow = 1, blue = 2, red = 3, green = 4;
string dir = "WSENHT";
int i, j, k, l, m;
char get_dir(int col, vector<int> subset={1,2,3,4}){
int pos = 4;
for(auto u : subset){
else if(u==2 and k==col) pos=1;
if(u==1 and j==col) pos=0;
else if(u==4 and m==col) pos=3;
else if(u==3 and l==col) pos=2;
}
return dir[pos];
}
bool exists_neighbour(int col, vector<int> subset={1,2,3,4}){
for(auto u : subset){
if(u==2 and k==col) return true;
if(u==1 and j==col) return true;
if(u==4 and m==col) return true;
if(u==3 and l==col) return true;
}
return false;
}
void program_pulibot()
{
for(i = 0; i <= 4; i++){
for(j = -2; j <= 4; j++){
for(k = -2; k <= 4; k++){
for(l = -2; l <= 4; l++){
for(m = -2; m <= 4; m++){
if(k==boundary and l==boundary){
// final location, start coloring with yellow, go back to last blue
set_instruction({i,j,k,l,m},yellow,get_dir(blue));
}
else if(exists_neighbour(green)){
// if green somewhere, we are in the final backtrack phase
// in this phase, we are going to make sure we backtrack to the right path
if(exists_neighbour(red)){
set_instruction({i,j,k,l,m},green,get_dir(red));
}
else{
// if we are in a blocked place already, clear it, traverse back
set_instruction({i,j,k,l,m},white,get_dir(green));
}
}
else if(i==green){
set_instruction({i,j,k,l,m},white,get_dir(yellow));
}
else if(exists_neighbour(yellow)){
// if yellow somewhere, we are in the final phase
// in this phase, we are going to remove all the extraneous colors
if(exists_neighbour(red)){
// firstly if there's red cell, go there while marking here as yellow
// if i'm already on a red cell tho, paint it green
set_instruction({i,j,k,l,m},(i==red?green: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(j==boundary and m==boundary){
// starting location we can terminate now
set_instruction({i,j,k,l,m},yellow,'T');
}
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,{2,3})){
// if still in the exploration phase and we can explore down or right:
// go to the next unvisited position
set_instruction({i,j,k,l,m},blue,get_dir(white,{2,3}));
}
else if(exists_neighbour(blue)){
// no where to go, mark as blocked, backtrack
set_instruction({i,j,k,l,m},red,get_dir(blue));
}
}
}
}
}
}
}