| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1322424 | seoul_korea | Robot Contest (IOI23_robot) | C++20 | 0 ms | 0 KiB |
#include "robot.h"
#include <bits/stdc++.h>
using namespace std;
const int UNVIS = 0;
const int FRONT = 2;
const int DONE = 3;
const int PATH = 8;
void add(vector<int> S,int Z,char A){
set_instruction(S.data(),Z,A);
}
bool empty(int x){ return x>=0; }
int dirColor[4]={4,5,6,7}; // W,S,E,N
void program_pulibot(){
vector<int> vals={-2,-1,0,2,3,4,5,6,7,8};
for(int c:vals)for(int w:vals)for(int s:vals)
for(int e:vals)for(int n:vals){
vector<int> S={c,w,s,e,n};
// step1: expand BFS frontier
if(c==FRONT){
if(w==UNVIS){ add(S,4,'W'); continue; }
if(s==UNVIS){ add(S,5,'S'); continue; }
if(e==UNVIS){ add(S,6,'E'); continue; }
if(n==UNVIS){ add(S,7,'N'); continue; }
add(S,DONE,'H');
continue;
}
// follow parent pointers backwards to paint path
if(c>=4 && c<=7){
if(c==4) add(S,PATH,'E');
if(c==5) add(S,PATH,'N');
if(c==6) add(S,PATH,'W');
if(c==7) add(S,PATH,'S');
continue;
}
// idle sweeping movement (snake scan)
if(empty(e)) add(S,c,'E');
else if(empty(s)) add(S,c,'S');
else add(S,c,'T');
}
}
