Submission #848165

#TimeUsernameProblemLanguageResultExecution timeMemory
848165I_love_Hoang_YenRobot Contest (IOI23_robot)C++17
26 / 100
116 ms7264 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++)
 
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 = 6;
    const int TO_CLEAN_UP = 7;
    const int CLEAN_RIGHT = 8;
    const int CLEAN_DOWN = 9;
 
#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};

        // Clean up
        if (cur == CLEAN_DOWN) {
            if (south == 0) {
                if (east == TO_CLEAN_UP) SET(CLEAN_RIGHT, 'H');
                if (north == CLEAN_DOWN) SET(0, 'N');
                SET(CLEAN_RIGHT, 'H');
            }
        }
        if (cur == TO_CLEAN_UP) {
            if (west == FINAL) SET(CLEAN_RIGHT, 'H');
            if (north == CLEAN_DOWN) {
                if (east == TO_CLEAN_UP) SET(CLEAN_RIGHT, 'H');
                if (south == TO_CLEAN_UP) SET(CLEAN_DOWN, 'S');
                SET(0, 'N');
            }
            if (west == CLEAN_RIGHT) {
                SET(CLEAN_RIGHT, 'H');
            }
        }
        if (cur == CLEAN_RIGHT) {
            if (south == TO_CLEAN_UP) SET(CLEAN_DOWN, 'S');
            if (east == TO_CLEAN_UP) SET(CLEAN_RIGHT, 'E');
            if (north == CLEAN_DOWN) SET(0, 'N');
            SET(0, 'W');
        }
 
        // Found target
        if (cur == FINAL) {
            if (east == TO_CLEAN_UP) SET(FINAL, 'E');

            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 ((south == BOUNDARY && east == BOUNDARY) || west == FINAL || south == FINAL || east == FINAL || north == FINAL) {
            SET(FINAL, 'H');
        }
 
        if (cur == 0) SET(TRY_EAST, 'H');
 
        if (cur == TRY_EAST) SET(TRY_SOUTH, east == 0 ? 'E' : 'H');
        if (cur == TRY_SOUTH) SET(BACKTRACK, 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(TO_CLEAN_UP, 'N');
            if (west > 0) SET(TO_CLEAN_UP, 'W');
            if (south > 0) SET(TO_CLEAN_UP, 'S');
            if (east > 0) SET(TO_CLEAN_UP, 'E');
        }
    }
}
 
void program_pulibot() {
    subtask3();
}

Compilation message (stderr)

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