이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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++)
void subtask1() {
FOR(cur,0,1) FOR(west,-2,1) FOR(south,-2,1) FOR(east,-2,1) FOR(north,-2,1) {
vector<int> state {cur, west, south, east, north};
if (south == -2 && east == -2) { // final state -> terminate
set_instruction(state, 1, 'T');
} else if (east == -2) {
set_instruction(state, 1, 'S');
} else {
set_instruction(state, 1, 'E');
}
}
}
void subtask2() {
FOR(cur,0,1) FOR(west,-2,1) FOR(south,-2,1) FOR(east,-2,1) FOR(north,-2,1) {
vector<int> state {cur, west, south, east, north};
if (south == -2 && east == -2) { // final state -> terminate
set_instruction(state, 1, 'T');
} else if (east == 0) {
set_instruction(state, 1, 'E');
} else if (south == 0) {
set_instruction(state, 1, 'S');
} else if (north == 0) {
set_instruction(state, 1, 'N');
}
}
}
void subtask3() {
const int MAX_COLOR = 10;
const int BOUNDARY = -2;
const int BLOCKED = -1;
const int FINAL = 1;
const int TRY_EAST = 2;
const int TRY_SOUTH = 3;
const int TRY_WEST = 4;
const int TRY_NORTH = 5;
const int BACKTRACK = 10;
#define SET(color, action) { set_instruction(state, color, action); continue; }
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};
// Found target
if ((south == BOUNDARY && east == BOUNDARY) || west == FINAL || south == FINAL || east == FINAL || north == FINAL) {
if (north > 1) SET(FINAL, 'N');
if (west > 1) SET(FINAL, 'W');
if (south > 1) SET(FINAL, 'S');
if (east > 1) SET(FINAL, 'E');
SET(FINAL, 'T');
}
if (cur == 0) SET(TRY_EAST, 'H');
if (cur == TRY_EAST) SET(TRY_SOUTH, east == 0 ? 'E' : 'H');
if (cur == TRY_SOUTH) SET(TRY_WEST, south == 0 ? 'S' : 'H');
if (cur == TRY_WEST) SET(TRY_NORTH, west == 0 ? 'W' : 'H');
if (cur == TRY_NORTH) SET(BACKTRACK, north == 0 ? 'N' : 'H');
if (cur == BACKTRACK) {
if (north > 0) SET(0, 'N');
if (west > 0) SET(0, 'W');
if (south > 0) SET(0, 'S');
if (east > 0) SET(0, 'E');
}
}
}
void program_pulibot() {
subtask3();
}
컴파일 시 표준 에러 (stderr) 메시지
robot.cpp: In function 'void subtask3()':
robot.cpp:39:15: warning: unused variable 'BLOCKED' [-Wunused-variable]
39 | const int BLOCKED = -1;
| ^~~~~~~
# | 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... |