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"
#define sz(x) (int)x.size()
using namespace std;
void program_pulibot()
{
string ord = "WSEN";
auto go = [&](vector<int> v) {
vector<int> repl{-2, -1, 0, 1, 2, 3, 4, 5, 6};
auto dfs = [&](auto&& s, vector<int> cur, int on) -> void {
if (on == 5) {
if (!cur[0]) {
set_instruction(cur, 2, 'H');
}
else if (cur[0] == 2) {
bool finishing = 0;
for (int i = 1; i < 5; i++) if (cur[i] == 1) finishing = 1;
if (finishing) {
goto fin;
}
if (cur[2] == -2 && cur[3] == -2) {
set_instruction(cur, 1, 'H');
}
else {
bool found = 0;
for (int i = 1; i < 5; i++) if (!cur[i]) {
set_instruction(cur, 2, ord[i-1]);
found = 1;
break;
}
if (!found) {
for (int i = 1; i < 5; i++) if (cur[i] == 2) {
set_instruction(cur, 3, ord[i-1]);
break;
}
}
}
}
else if (cur[0] == 3) {
bool found = 0;
for (int i = 1; i < 5; i++) if (cur[i] == 3) {
set_instruction(cur, 4, ord[i-1]);
found = 1;
break;
}
if (!found) {
for (int i = 1; i < 5; i++) if (cur[i] == 1 || cur[i] == 4) {
set_instruction(cur, 0, ord[i-1]);
break;
}
}
}
else if (cur[0] == 1) {
fin:;
bool found = 0;
for (int i = 1; i < 5; i++) if (cur[i] == 3) {
found = 1;
set_instruction(cur, 1, ord[i-1]);
break;
}
if (!found) {
for (int i = 1; i < 5; i++) if (cur[i] == 2) {
found = 1;
set_instruction(cur, 1, ord[i-1]); break;
}
}
if (!found) {
set_instruction(cur, 1, 'T');
}
}
else if (cur[0] == 4) {
bool found = 0;
for (int i = 1; i < 5; i++) if (cur[i] == 3) {
found = 1;
set_instruction(cur, 4, ord[i-1]);
break;
}
if (!found) {
for (int i = 1; i < 5; i++) if (cur[i] == 1 || cur[i] == 4) {
set_instruction(cur, 0, ord[i-1]);
break;
}
}
}
return;
}
if (v[on] == -3) {
for (int p : repl) {
cur[on] = p;
s(s, cur, on+1);
}
}
else s(s, cur, on+1);
};
dfs(dfs, v, 0);
};
go({0, -3, -3, -3, -3});
go({1, -3, -3, -3, -3});
go({2, -3, -3, -3, -3});
go({3, -3, -3, -3, -3});
go({4, -3, -3, -3, -3});
}
# | 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... |