#include "robot.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
pair<int,char> calc_instruction(vi S) {
// S[0] = (r,c)
// S[1] = (r,c-1) - west ***
// S[2] = (r+1, c) - south **
// S[3] = (r,c+1) - east *
// S[4] = (r-1, c) - north ****
int ind[4] = {3,2,1,4};
char c[5] = {'E','S','W','N','H'};
// se tiver 1 ou a casinha atual for o final
if(S[0] == 1) return {1, 'T'};
int prox = 4;
bool one = (S[1] == -2 and S[2] == -2);
for(int i = 0; i < 4; i++) {
if(S[ind[i]] == 1) one = 1;
else if(S[ind[i]] >= 0) prox = i;
}
if(one) return {1, c[prox]};
// acabou o caso
for(int val = 0; val < 5; val++) {
if(S[0] != val) continue;
int Z = max(2, val+1);
char A = 'H';
if(S[ind[max(0,val-1)]] == 0)
A = c[max(0,val-1)];
return {Z, A};
}
return {6, 'T'}; // quando deu erro
}
void program_pulibot() {
for(int mask = 0; mask < 32768; mask++) {
vi S(5);
int m = mask;
for(int i = 0; i < 5; i++)
S[i] = m%8 - 2, m /= 8;
auto [Z,A] = calc_instruction(S);
set_instruction(S, Z, A);
}
}
# | 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... |