#include "robot.h"
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define lf ((id<<1))
#define rg ((id<<1)|1)
#define md ((l+r)>>1)
#define make set_instruction
using namespace std;
typedef pair<ll,ll> pii;
typedef pair<pii,ll> ipii;
typedef pair<vector<int>, int> pvi;
const int MAXN = 1e3+10;
void chmx(auto &a, auto b){ a = max(a, b); }
void chmn(auto &a, auto b){ a = min(a, b); }
// nw, le, dw, ri, up
map<vector<int>, int> ma;
int i,a,b,c,d;
void bd(int col, char p){
vector<int> x; x.pb(i); x.pb(c); x.pb(b); x.pb(a); x.pb(d);
// if(ma[x] == 1){
// cout << i << ' ' << c << ' ' << b << ' ' << a << ' ' << d << " pp\n";
// }
// ma[x]++;
make(x, col, p);
}
void solve(){
if(a==-2 && b==-2){ // bawah kanan
if(c>0){
bd(1, 'W'); return;
}
if(d>0){
bd(1, 'N'); return;
}
return;
}
bool nxsatu = 0;
if(a==1||b==1||c==1||d==1) nxsatu = 1;
if(nxsatu && c==-2 && d==-2){ // kiri atas kelar
bd(1, 'T');
return;
}
if(nxsatu){
if(c>1){
bd(1, 'W'); return;
}
if(d>1){
bd(1, 'N'); return;
}
if(a>1){
bd(1, 'E'); return;
}
if(b>1){
bd(1, 'S'); return;
}
return;
}
int can = 0; // bisa ke mana
int nw = i;
if(nw>0) nw--;
if( (nw&1) == 0 && a==0) can++;
if( (nw&2) == 0 && b==0) can += 2;
if( (nw&4) == 0 && c==0) can += 4;
if( (nw&8) == 0 && d==0) can += 8;
if(can & 1){ // E
bd((nw|1) + 1, 'E'); // ban ke E
return;
} else if(can & 2){ // S
bd((nw|2) + 1, 'S');
return;
} else if(can & 4){ // S
bd((nw|4) + 1, 'W');
return;
} else if(can & 8){ // S
bd((nw|8) + 1, 'N');
return;
} else { // can = 0
// mundur
can = 0;
if(c>0){
bd(0, 'W'); return;
}
if(d>0){
bd(0, 'N'); return;
}
if(a>0){
bd(0, 'E'); return;
}
if(b>0){
bd(0, 'S'); return;
}
}
}
void program_pulibot()
{
for(int ia=0; ia<=16; ia++){
for(int aa=-2; aa<=16; aa++){ // E
for(int ba=-2; ba<=16; ba++){ // S
for(int ca=-2; ca<=16; ca++){ // W
for(int da=-2; da<=16; da++){ // N
i = ia; a = aa; b = ba; c = ca; d = da;
solve();
}
}
}
}
}
}
# | 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... |