# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1214051 | Nelt | Robot Contest (IOI23_robot) | C++20 | 0 ms | 0 KiB |
#include "robot.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define endl "\n"
using namespace std;
using namespace __gnu_pbds;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T, typename key = less<T>>
using ordered_set = tree<T, null_type, key, rb_tree_tag, tree_order_statistics_node_update>;
void program_pulibot()
{
auto move = [&](ll x) -> char
{
if (x == 2) return 'W';
if (x == 3) return 'S';
if (x == 4) return 'E';
return 'N';
};
ll v[] = {-2, -1, 0, 1, 2, 3, 4, 5};
for (ll s0 : v)
for (ll s1 : v)
for (ll s2 : v)
for (ll s3 : v)
for (ll s4 : v)
{
ll S[5] = {s0, s1, s2, s3, s4};
if (s0 == 0)
{
bool ok = 0;
for (ll d = 0; d < 4; d++)
{
if (S[d + 1] == 0)
{
set_instruction(S, 2 + d, move(2 + d));
ok = 1;
break;
}
}
if (ok) continue;
if (s2 == -2 && s3 == -2)
{
set_instruction(S, 1, 'T');
continue;
}
for (ll d = 0; d < 4; d++)
{
ll opp = 2 + (d ^ 1);
if (S[d + 1] == opp)
{
set_instruction(S, 1, move(2 + (d ^ 1)));
ok = 1;
break;
}
}
if (ok) continue;
}
if (s0 >= 2 && s0 <= 5)
{
set_instruction(S, 1, move(s0));
continue;
}
set_instruction(S, 0, 'H');
}
}