#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(i>=4){
// if(a==-2 && b==-2){
// bd(1, 'T'); return;
// }
// if(a==4){
// bd(1, 'E'); return;
// }
// if(b==4){
// bd(1, 'S'); return;
// }
// }
if(i >= 4){
int can = 0; // bisa ke mana
if(a>1) can += 1;
if(b>1) can += 2;
if(can & 2){ // S
bd(i|2, 'S');
return;
} else if(can & 1){ // E
bd(i|1, 'E'); // ban ke E
return;
} else { // can = 0
if(c==-2 && d==-2){
bd(1, 'T');
return;
}
// mundur
if(c>1){ // udh ke vis
if(i&4) bd(1, 'W');
else bd(0, 'W');
return;
}
if(d>1){
if(i&4) bd(1, 'N');
else bd(0, 'N');
return;
}
}
return;
}
if(a==-2 && b==-2){ // bawah kanan
if(c>0){
bd(4, 'W'); return;
}
if(d>0){
bd(4, 'N'); return;
}
return;
}
bool nxsatu = 0;
if(a==4||b==4||c==4||d==4) nxsatu = 1;
if(nxsatu && c==-2 && d==-2){ // kiri atas kelar
bd(12, 'H');
return;
}
if(nxsatu){
if(c>0){
bd(4, 'W'); return;
}
if(d>0){
bd(4, 'N'); return;
}
return;
}
int can = 0; // bisa ke mana
int nw = i;
if( (nw&1) == 0 && a==0) can++;
if( (nw&2) == 0 && b==0) can += 2;
if(can & 2){ // S
bd((nw|2), 'S');
return;
} else if(can & 1){ // E
bd((nw|1), 'E'); // ban ke E
return;
} else { // can = 0
// mundur
// tag sebagai ban node = 8
if(c>0){
bd(8, 'W'); return;
}
if(d>0){
bd(8, 'N'); return;
}
}
}
void program_pulibot()
{
for(int ia=0; ia<=17; ia++){
for(int aa=-2; aa<=17; aa++){ // E
for(int ba=-2; ba<=17; ba++){ // S
for(int ca=-2; ca<=17; ca++){ // W
for(int da=-2; da<=17; 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... |