제출 #879973

#제출 시각아이디문제언어결과실행 시간메모리
879973SanguineChameleon로봇 대회 (IOI23_robot)C++17
100 / 100
103 ms6192 KiB
#include "robot.h" #include <bits/stdc++.h> using namespace std; const string dirs = "NESW"; const int STAY = -1; const int STOP = -2; const int OBST = -1; const int WALL = -2; const int NORTH = 0; const int EAST = 1; const int SOUTH = 2; const int WEST = 3; const int EMPTY = 4; const int PATH = 5; pair<int, int> calc(int cur, vector<int> adj) { int phase = ((cur == EMPTY) || (0 <= cur && cur < 4 && adj[cur] == (cur ^ 2)) ? 1 : 2); if (phase == 1) { if (cur == EMPTY && adj[NORTH] == WALL && adj[WEST] == WALL) { for (int d = 0; d < 4; d++) { if (adj[d] == EMPTY) { return {d, d}; } } return {EMPTY, STOP}; } if (cur == EMPTY && adj[SOUTH] == WALL && adj[EAST] == WALL) { return {EAST, STAY}; } if (cur == EMPTY) { for (int d = 0; d < 4; d++) { if (adj[d] == (d ^ 2)) { return {d, d}; } } return {EMPTY, STOP}; } for (int d = 0; d < 4; d++) { cur = (cur + 1) % 4; if (adj[cur] == EMPTY || adj[cur] == (cur ^ 2)) { return {cur, cur}; } } return {EMPTY, STOP}; } else { for (int d = 0; d < 4; d++) { if (adj[d] == (d ^ 2)) { return {cur, d}; } } if (adj[NORTH] == WALL && adj[WEST] == WALL) { return {PATH, cur}; } for (int d = 0; d < 4; d++) { if (adj[d] == PATH) { if (adj[SOUTH] == WALL && adj[EAST] == WALL) { return {PATH, STOP}; } return {PATH, cur}; } } return {EMPTY, cur}; } } int shift(int Z, int K) { return (Z < 0 ? Z : (Z + K) % 6); } void program_pulibot() { for (int cur = 0; cur <= 5; cur++) { if (cur == 1) { continue; } for (int N = -2; N <= 5; N++) { for (int E = -2; E <= 5; E++) { for (int S = -2; S <= 5; S++) { for (int W = -2; W <= 5; W++) { auto inst = calc(shift(cur, 4), {shift(N, 4), shift(E, 4), shift(S, 4), shift(W, 4)}); int Z = shift(inst.first, 2); char A = (inst.second == STAY ? 'H' : (inst.second == STOP ? 'T' : dirs[inst.second])); set_instruction({cur, W, S, E, N}, Z, A); } } } } } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...