| # | Time | Username | Problem | Language | Result | Execution time | Memory |
|---|---|---|---|---|---|---|---|
| 1322425 | seoul_korea | Robot Contest (IOI23_robot) | C++20 | 0 ms | 0 KiB |
#include "robot.h"
const int UNVIS = 0;
const int FRONT = 2;
const int DONE = 3;
const int PATH = 8;
void add(int c,int w,int s,int e,int n,int Z,char A){
int S[5] = {c,w,s,e,n};
set_instruction(S,Z,A);
}
bool empty(int x){ return x >= 0; }
void program_pulibot() {
int vals[] = {-2,-1,0,2,3,4,5,6,7,8};
int V = 10;
for(int i0=0;i0<V;i0++)
for(int i1=0;i1<V;i1++)
for(int i2=0;i2<V;i2++)
for(int i3=0;i3<V;i3++)
for(int i4=0;i4<V;i4++){
int c=vals[i0];
int w=vals[i1];
int s=vals[i2];
int e=vals[i3];
int n=vals[i4];
// expand BFS frontier
if(c==FRONT){
if(w==UNVIS){ add(c,w,s,e,n,4,'W'); continue; }
if(s==UNVIS){ add(c,w,s,e,n,5,'S'); continue; }
if(e==UNVIS){ add(c,w,s,e,n,6,'E'); continue; }
if(n==UNVIS){ add(c,w,s,e,n,7,'N'); continue; }
add(c,w,s,e,n,DONE,'H');
continue;
}
// follow parent pointers → paint shortest path
if(c>=4 && c<=7){
if(c==4) add(c,w,s,e,n,PATH,'E');
else if(c==5) add(c,w,s,e,n,PATH,'N');
else if(c==6) add(c,w,s,e,n,PATH,'W');
else if(c==7) add(c,w,s,e,n,PATH,'S');
continue;
}
// sweeping movement (scan whole grid forever)
if(empty(e)) add(c,w,s,e,n,c,'E');
else if(empty(s)) add(c,w,s,e,n,c,'S');
else add(c,w,s,e,n,c,'T');
}
}
