# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1017876 | tmarcinkevicius | Robot Contest (IOI23_robot) | C++17 | 0 ms | 0 KiB |
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>
using namespace std;
#include "robot.h"
typedef pair<int, int> pii;
#define f first
#define s second
const int maxColor = 4;
/*
0 - unvisited
1 - final
2 - explore
3 - bad way
4 - bad way fix
*/
void program_pulibot()
{
vector<int> S(5);
vector<pair<int, char>> directions =
{
{3, 'E'}, {2, 'S'}, {1, 'W'}, {4, 'N'}};
for (S[0] = 0; S[0] <= maxColor; S[0]++)
{
for (S[1] = -2; S[1] <= maxColor; S[1]++)
{
for (S[2] = -2; S[2] <= maxColor; S[2]++)
{
for (S[3] = -2; S[3] <= maxColor; S[3]++)
{
for (S[4] = -2; S[4] <= maxColor; S[4]++)
{
if (S[0] == 4)
{
bool found = false;
for (auto p : directions)
{
if (S[p.f] == 3)
{
set_instruction(S, 4, p.s);
found = true;
break;
}
}
if (found)
continue;
found = false;
for (auto p : directions)
{
if (S[p.f] == 4)
{
set_instruction(S, 0, p.s);
found = true;
break;
}
}
if (found)
continue;
for (auto p : directions)
{
if (S[p.f] == 2)
{
set_instruction(S, 1, p.s);
found = true;
break;
}
}
if (found)
continue;
if (S[1] == -2 && S[4] == -2)
{
set_instruction(S, 1, 'T');
}
continue;
}
if (S[0] == 3)
{
bool found = false;
reverse(all(directions));
for (auto p : directions)
{
if (S[p.f] == 3)
{
set_instruction(S, 4, p.s);
found = true;
break;
}
}
reverse(all(directions));
if (found)
continue;
for (auto p : directions)
{
if (S[p.f] == 4)
{
set_instruction(S, 0, p.s);
found = true;
break;
}
}
if (found)
continue;
if (S[1] == -2 && S[4] == -2)
{
set_instruction(S, 1, 'T');
}
continue;
}
bool found1 = false;
for (auto p : directions)
{
if (S[p.f] == 1)
{
found1 = true;
break;
}
}
if (found1)
{
bool found = false;
for (auto p : directions)
{
if (S[p.f] == 3)
{
set_instruction(S, 4, p.s);
found = true;
break;
}
}
if (found)
continue;
if (S[1] == -2 && S[4] == -2)
{
set_instruction(S, 1, 'T');
continue;
}
for (auto p : directions)
{
if (S[p.f] == 2)
{
set_instruction(S, 1, p.s);
break;
}
}
continue;
}
if (S[0] == 0 || S[0] == 2)
{
if (S[2] == -2 && S[3] == -2)
{
for (auto p : directions)
{
if (S[p.f] == 2)
{
set_instruction(S, 1, p.s);
break;
}
}
continue;
}
bool found = false;
for (auto p : directions)
{
if (S[p.f] == 0 && p.s != 'N' && p.s != 'W')
{
set_instruction(S, 2, p.s);
found = true;
break;
}
}
if (found)
continue;
for (auto p : directions)
{
if (S[p.f] == 2)
{
set_instruction(S, 3, p.s);
break;
}
}
}
}
}
}
}
}
}