| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 1332586 | AksLolCoding | 로봇 대회 (IOI23_robot) | C++17 | 64 ms | 5940 KiB |
#include "robot.h"
#include <bits/stdc++.h>
#define ll long long
#define el cout << endl
#define DEBUG(...) [](auto &&...x) {int i = 0; ((cout << (i++ ? " " : "") << x), ...), el;} (__VA_ARGS__)
using namespace std;
const char DIR[] = {'W', 'S', 'E', 'N'};
const int COLOR[] = {2, 3, 4, 5};
namespace SUBTASK_AC
{
bool is_direct(int col)
{
return col >= 2 && col <= 5;
}
bool is_inver(int color_a, int pos_b, int color_b)
{
if (!is_direct(color_a) || !is_direct(color_b))
return 0;
if (abs(color_a - color_b) != 2)
return 0;
int pos_a = color_a - 2;
return pos_a == pos_b;
}
void gen_bfs()
{
auto gen_empty = [&] ()
{
vector<int> val = {-2, -1, 0, 2, 3, 4, 5};
for (int y : {-1, 0})
for (int p : {-1, 0})
{
int x = -2;
int q = -2;
if (y == 0)
set_instruction({0, x, y, p, q}, COLOR[1], DIR[1]);
else if (p == 0)
set_instruction({0, x, y, p, q}, COLOR[2], DIR[2]);
}
for (int x : val)
for (int y : val)
for (int p : val)
for (int q : val)
{
vector<int> v = {x, y, p, q};
vector<int> dir = {0, 1, 2, 3};
function<bool()> check_state = [=] () -> bool
{
if (x == -2 && q == -2)
return 0;
if (y == -2 && p == -2)
return 0;
int cnt = 0;
for (int k : dir)
cnt += is_inver(COLOR[k], k, v[k]);
return cnt == 1;
};
if (!check_state())
continue;
for (int k : dir)
if (is_inver(COLOR[k], k, v[k]))
{
set_instruction({0, x, y, p, q}, COLOR[k], DIR[k]);
}
}
};
auto gen_state = [&] ()
{
vector<int> val = {-2, -1, 0, 2, 3, 4, 5};
for (int state : COLOR)
for (int x : val)
for (int y : val)
for (int p : val)
for (int q : val)
{
vector<int> v = {x, y, p, q};
vector<int> dir;
if (!is_inver(state, state - 2, v[state - 2]))
continue;
dir.push_back((state + 3) % 4);
for (int _ = 0; _ < 3; _++)
dir.push_back((dir.back() + 1) % 4);
for (int k : dir)
{
if (v[k] == 0 || is_inver(COLOR[k], k, v[k]))
{
set_instruction({state, x, y, p, q}, COLOR[k], DIR[k]);
break;
}
}
}
};
gen_empty();
gen_state();
}
void gen_ans()
{
auto gen_en = [=] ()
{
vector<int> val = {-1, 0, 1, 2, 3, 4, 5};
for (int x : val)
for (int q : val)
{
int y = -2;
int p = -2;
if (is_inver(COLOR[0], 0, x))
set_instruction({0, x, y, p, q}, COLOR[2], DIR[0]);
else if (is_inver(COLOR[3], 3, q))
set_instruction({0, x, y, p, q}, COLOR[1], DIR[3]);
if (x == 1 || q == 1)
for (int state : COLOR)
set_instruction({state, x, y, p, q}, 1, 'T');
}
};
auto gen_st = [=] ()
{
vector<int> val = {-1, 0, 2, 3, 4, 5};
for (int state : COLOR)
{
for (int y : val)
for (int p : val)
{
int x = -2;
int q = -2;
if (is_inver(COLOR[1], 1, y) || is_inver(COLOR[2], 2, p))
continue;
if (is_direct(y))
set_instruction({state, x, y, p, q}, 1, DIR[1]);
else if (is_direct(p))
set_instruction({state, x, y, p, q}, 1, DIR[2]);
}
}
};
auto gen_dfs = [=] ()
{
vector<int> val = {-2, -1, 0, 1, 2, 3, 4, 5};
for (int state : COLOR)
for (int x : val)
for (int y : val)
for (int p : val)
for (int q : val)
{
vector<int> v = {x, y, p, q};
vector<int> dir = {0, 1, 2, 3};
int cnt1 = 0;
auto check_state = [&] () -> bool
{
if (x == -2 && q == -2)
{
int cnt = 0;
for (int k : dir)
cnt += is_inver(COLOR[k], k, v[k]);
return !is_inver(state, state - 2, v[state - 2]) && cnt;
}
if (y == -2 && p == -2)
return 0;
for (int k : dir)
cnt1 += v[k] == 1;
return cnt1 <= 1 && !is_inver(state, state - 2, v[state - 2]);
};
if (!check_state())
continue;
bool flag = 0;
for (int k : dir)
if (is_inver(COLOR[k], k, v[k]))
{
set_instruction({state, x, y, p, q}, state, DIR[k]);
flag = 1;
break;
}
if (flag)
continue;
for (int C : dir)
cnt1 += v[C] == 1;
if (cnt1)
set_instruction({state, x, y, p, q}, 1, DIR[state - 2]);
else
set_instruction({state, x, y, p, q}, 0, DIR[state - 2]);
}
};
gen_en();
gen_st();
gen_dfs();
}
void program_pulibot()
{
gen_bfs();
gen_ans();
}
}
void program_pulibot()
{
SUBTASK_AC::program_pulibot();
}| # | 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... | ||||
