Submission #941925

#TimeUsernameProblemLanguageResultExecution timeMemory
941925benjaminkleynRobot Contest (IOI23_robot)C++17
100 / 100
112 ms6484 KiB
#include <bits/stdc++.h> using namespace std; #include "robot.h" const int BOUNDARY = -2; const int OBSTACLE = -1; const int EMPTY = 0; const int PATH = 1; const int WEST = 2; const int SOUTH = 3; const int EAST = 4; const int NORTH = 5; const char STAY = 'H'; const char TERMINATE = 'T'; bool phase2(int cur, int west, int south, int east, int north) { if (cur == EMPTY) return false; if (cur == WEST) return west != EAST; if (cur == SOUTH) return south != NORTH; if (cur == EAST) return east != WEST; if (cur == NORTH) return north != SOUTH; return false; } pair<int, char> get_instruction(int cur, int west, int south, int east, int north) { if (east == BOUNDARY && south == BOUNDARY && cur == EMPTY) return {EAST, STAY}; if (phase2(cur, west, south, east, north)) { if (west == EAST) return {cur, 'W'}; if (south == NORTH) return {cur, 'S'}; if (east == WEST) return {cur, 'E'}; if (north == SOUTH) return {cur, 'N'}; if (east == BOUNDARY && south == BOUNDARY) return {PATH, TERMINATE}; char dir; if (cur == WEST) dir = 'W'; else if (cur == SOUTH) dir = 'S'; else if (cur == EAST) dir = 'E'; else dir = 'N'; if ((west == BOUNDARY && north == BOUNDARY) || west == PATH || south == PATH || east == PATH || north == PATH) return {PATH, dir}; return {EMPTY, dir}; } if (west == BOUNDARY && north == BOUNDARY && cur == EMPTY) { if (south == OBSTACLE) return {EAST, 'E'}; return {SOUTH, 'S'}; } if (cur == EMPTY) { if (west == EAST) return {WEST, 'W'}; if (south == NORTH) return {SOUTH, 'S'}; if (east == WEST) return {EAST, 'E'}; if (north == SOUTH) return {NORTH, 'N'}; return {0, TERMINATE}; } for (int i = 0; i < 4; i++) { if (cur == WEST) { cur = NORTH; if (north == EMPTY || north == SOUTH) return {NORTH, 'N'}; } else if (cur == SOUTH) { cur = WEST; if (west == EMPTY || west == EAST) return {WEST, 'W'}; } else if (cur == EAST) { cur = SOUTH; if (south == EMPTY || south == NORTH) return {SOUTH, 'S'}; } else if (cur == NORTH) { cur = EAST; if (east == EMPTY || east == WEST) return {EAST, 'E'}; } else cur = WEST; } return {0, TERMINATE}; } void program_pulibot() { for (int cur = -2; cur <= 6; cur++) for (int west = -2; west <= 6; west++) for (int south = -2; south <= 6; south++) for (int east = -2; east <= 6; east++) for (int north = -2; north <= 6; north++) { pair<int, char> instruction = get_instruction(cur, west, south, east, north); set_instruction({cur, west, south, east, north}, instruction.first, instruction.second); } }
#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...