Submission #848176

#TimeUsernameProblemLanguageResultExecution timeMemory
848176I_love_Hoang_YenRobot Contest (IOI23_robot)C++17
12 / 100
132 ms7192 KiB
#include "robot.h" #include <bits/stdc++.h> using namespace std; #define FOR(i,a,b) for(int i=(a),_##i##_b=(b); i<=_##i##_b; i++) #define SET(color, action) { set_instruction(state, color, action); continue; } void subtask3() { const int MAX_COLOR = 10; const int BOUNDARY = -2; const int BLOCKED = -1; const int FINAL = 1; // directions const int TO_SOUTH = 2; const int TO_EAST = 3; const int TO_NORTH = 4; const int TO_WEST = 5; // phase 2 const int PHASE2 = 6; FOR(cur,0,MAX_COLOR) FOR(west,-2,MAX_COLOR) FOR(south,-2,MAX_COLOR) FOR(east,-2,MAX_COLOR) FOR(north,-2,MAX_COLOR) { vector<int> state {cur, west, south, east, north}; // Phase 3 if (cur == FINAL) { if (south == BOUNDARY && east == BOUNDARY) SET(FINAL, 'T'); if (north == PHASE2) SET(FINAL, 'N'); if (south == PHASE2) SET(FINAL, 'S'); if (east == PHASE2) SET(FINAL, 'E'); if (west == PHASE2) SET(FINAL, 'W'); } // Phase 2 if (north == PHASE2 || south == PHASE2 || east == PHASE2 || west == PHASE2 || cur == PHASE2) { if (north == BOUNDARY && west == BOUNDARY) SET(FINAL, 'H'); if (north == FINAL || south == FINAL || east == FINAL || west == FINAL) SET(FINAL, 'H'); if (north == TO_SOUTH) SET(PHASE2, 'N'); if (south == TO_NORTH) SET(PHASE2, 'S'); if (east == TO_WEST) SET(PHASE2, 'E'); if (west == TO_EAST) SET(PHASE2, 'W'); if (north == PHASE2) SET(0, 'N'); if (south == PHASE2) SET(0, 'S'); if (east == PHASE2) SET(0, 'E'); if (west == PHASE2) SET(0, 'W'); } // Reached final state if (south == BOUNDARY && east == BOUNDARY) { SET(PHASE2, 'H'); } // Starting state if (cur == 0 && north == BOUNDARY && west == BOUNDARY) { if (south == 0) SET(TO_SOUTH, 'S'); if (east == 0) SET(TO_EAST, 'E'); } // BFS if (cur == TO_SOUTH) { if (east == 0 || east == TO_WEST) SET(TO_EAST, 'E'); if (north == 0 || north == TO_SOUTH) SET(TO_NORTH, 'N'); if (west == 0 || west == TO_EAST) SET(TO_WEST, 'W'); if (south == 0 || south == TO_NORTH) SET(TO_SOUTH, 'S'); } if (cur == TO_EAST) { if (north == 0 || north == TO_SOUTH) SET(TO_NORTH, 'N'); if (west == 0 || west == TO_EAST) SET(TO_WEST, 'W'); if (south == 0 || south == TO_NORTH) SET(TO_SOUTH, 'S'); if (east == 0 || east == TO_WEST) SET(TO_EAST, 'E'); } if (cur == TO_NORTH) { if (west == 0 || west == TO_EAST) SET(TO_WEST, 'W'); if (south == 0 || south == TO_NORTH) SET(TO_SOUTH, 'S'); if (east == 0 || east == TO_WEST) SET(TO_EAST, 'E'); if (north == 0 || north == TO_SOUTH) SET(TO_NORTH, 'N'); } if (cur == TO_WEST) { if (south == 0 || south == TO_NORTH) SET(TO_SOUTH, 'S'); if (east == 0 || east == TO_WEST) SET(TO_EAST, 'E'); if (north == 0 || north == TO_SOUTH) SET(TO_NORTH, 'N'); if (west == 0 || west == TO_EAST) SET(TO_WEST, 'W'); } if (cur == 0) { if (north == TO_SOUTH) SET(TO_NORTH, 'N'); if (south == TO_NORTH) SET(TO_SOUTH, 'S'); if (east == TO_WEST) SET(TO_EAST, 'E'); if (west == TO_EAST) SET(TO_WEST, 'W'); } } } void program_pulibot() { subtask3(); }

Compilation message (stderr)

robot.cpp: In function 'void subtask3()':
robot.cpp:12:15: warning: unused variable 'BLOCKED' [-Wunused-variable]
   12 |     const int BLOCKED = -1;
      |               ^~~~~~~
#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...