This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
#include "robot.h"
using namespace std;
const int Z = 5;
const char key[] = "HTWSEN";
inline int opp(int d) {
return d ^ 6;
}
inline int nxt(int d) {
return (++d > Z ? d - 4 : d);
}
pair<int, char> solve(vector<int> S) {
vector<int> s = S;
s.insert(s.begin() + 1, 0);
bool tlcorner = s[2] == -2 && s[5] == -2,
brcorner = s[3] == -2 && s[4] == -2;
int d = s[0];
if (d == 0) {
if (brcorner) {
return {4, key[0]};
}
int nd = -1;
for (int k = 2; k <= 5; k++) {
if (opp(s[k]) == k) {
return {k, key[k]};
}
if (s[k] == 0 && nd == -1) {
nd = k;
}
}
if (tlcorner && nd != -1) {
return {nd, key[nd]};
}
} else if (opp(s[d]) == d) {
while (d = nxt(d)) {
if (opp(s[d]) == d || s[d] == 0) {
return {d, key[d]};
}
}
} else {
int cnt1 = 0;
for (int k = 2; k <= 5; k++) {
if (opp(s[k]) == k) {
return {d, key[k]};
}
cnt1 += s[k] == 1;
}
return {tlcorner || cnt1, key[brcorner ? 1 : d]};
}
return {0, key[0]};
}
void program_pulibot() {
for (int _m = 0; _m <= Z; _m++) {
for (int _w = -2; _w <= Z; _w++) {
for (int _s = -2; _s <= Z; _s++) {
for (int _e = -2; _e <= Z; _e++) {
for (int _n = -2; _n <= Z; _n++) {
vector<int> S({_m, _w, _s, _e, _n});
auto [Z, A] = solve(S);
set_instruction(S, Z, A);
}
}
}
}
}
}
Compilation message (stderr)
robot.cpp: In function 'std::pair<int, char> solve(std::vector<int>)':
robot.cpp:38:18: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
38 | while (d = nxt(d)) {
| ~~^~~~~~~~
# | 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... |