제출 #848190

#제출 시각아이디문제언어결과실행 시간메모리
848190I_love_Hoang_Yen로봇 대회 (IOI23_robot)C++17
88 / 100
128 ms7256 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 = 9; const int BOUNDARY = -2; const int BLOCKED = -1; const int FINAL = 1; // directions const int ONE_SOUTH = 2; const int ONE_EAST = 3; const int ONE_NORTH = 4; const int ONE_WEST = 5; // phase 2 const int TWO_SOUTH = 6; const int TWO_EAST = 7; const int TWO_NORTH = 8; const int TWO_WEST = 9; 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 >= 6) SET(FINAL, 'N'); if (south >= 6) SET(FINAL, 'S'); if (east >= 6) SET(FINAL, 'E'); if (west >= 6) SET(FINAL, 'W'); } // Phase 2 if (north >= 6 || south >= 6 || east >= 6 || west >= 6 || cur >= 6) { if (west == ONE_EAST) SET(cur >= 6 ? cur : cur + 4, 'W'); if (south == ONE_NORTH) SET(cur >= 6 ? cur : cur + 4, 'S'); if (east == ONE_WEST) SET(cur >= 6 ? cur : cur + 4, 'E'); if (north == ONE_SOUTH) SET(cur >= 6 ? cur : cur + 4, 'N'); if (north == BOUNDARY && west == BOUNDARY) SET(FINAL, 'H'); if (north == FINAL || south == FINAL || east == FINAL || west == FINAL) SET(FINAL, 'H'); if (cur == ONE_SOUTH || cur == TWO_SOUTH) SET(0, 'S'); if (cur == ONE_NORTH || cur == TWO_NORTH) SET(0, 'N'); if (cur == ONE_WEST || cur == TWO_WEST) SET(0, 'W'); if (cur == ONE_EAST || cur == TWO_EAST) SET(0, 'E'); } // Reached final state if (south == BOUNDARY && east == BOUNDARY) { SET(6, 'H'); } // Starting state if (cur == 0 && north == BOUNDARY && west == BOUNDARY) { if (south == 0) SET(ONE_SOUTH, 'S'); if (east == 0) SET(ONE_EAST, 'E'); } // BFS if (cur == ONE_SOUTH) { if (east == 0 || east == ONE_WEST) SET(ONE_EAST, 'E'); if (north == 0 || north == ONE_SOUTH) SET(ONE_NORTH, 'N'); if (west == 0 || west == ONE_EAST) SET(ONE_WEST, 'W'); if (south == 0 || south == ONE_NORTH) SET(ONE_SOUTH, 'S'); } if (cur == ONE_EAST) { if (north == 0 || north == ONE_SOUTH) SET(ONE_NORTH, 'N'); if (west == 0 || west == ONE_EAST) SET(ONE_WEST, 'W'); if (south == 0 || south == ONE_NORTH) SET(ONE_SOUTH, 'S'); if (east == 0 || east == ONE_WEST) SET(ONE_EAST, 'E'); } if (cur == ONE_NORTH) { if (west == 0 || west == ONE_EAST) SET(ONE_WEST, 'W'); if (south == 0 || south == ONE_NORTH) SET(ONE_SOUTH, 'S'); if (east == 0 || east == ONE_WEST) SET(ONE_EAST, 'E'); if (north == 0 || north == ONE_SOUTH) SET(ONE_NORTH, 'N'); } if (cur == ONE_WEST) { if (south == 0 || south == ONE_NORTH) SET(ONE_SOUTH, 'S'); if (east == 0 || east == ONE_WEST) SET(ONE_EAST, 'E'); if (north == 0 || north == ONE_SOUTH) SET(ONE_NORTH, 'N'); if (west == 0 || west == ONE_EAST) SET(ONE_WEST, 'W'); } if (cur == 0) { if (north == ONE_SOUTH) SET(ONE_NORTH, 'N'); if (south == ONE_NORTH) SET(ONE_SOUTH, 'S'); if (east == ONE_WEST) SET(ONE_EAST, 'E'); if (west == ONE_EAST) SET(ONE_WEST, 'W'); } } } void program_pulibot() { subtask3(); }

컴파일 시 표준 에러 (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...