Submission #1165305

#TimeUsernameProblemLanguageResultExecution timeMemory
1165305Dan4LifeRobot Contest (IOI23_robot)C++17
26 / 100
75 ms5960 KiB
#include "robot.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define sz(a) (int)a.size() using vi = vector<int>; const int BOUNDARY=-2, OBSTACLE=-1, WHITE=0, YELLOW=1, PURPLE=2, RED=3, ORANGE=4, PINK=5; const int HERE=0, LEFT=1, DOWN=2, RIGHT=3, UP=4, END=5; char dir[] = {'H','W','S','E','N','T'}; void Set(vi state, int col, int di){ set_instruction(state, col, di==-1?'T':dir[di]); } int findFirstNeighbour(vi state, int col, vi neigh={1,2,3,4}){ for(int i : neigh) if(state[i]==col) return i; return -1; } bool state_contains(vi state, int col, vi pick={0,1,2,3,4}){ for(int i : pick) if(state[i]==col) return 1; return 0; } void program_pulibot(){ int lb = -2, ub = 5; for(int here = lb; here <= ub; here++){ for(int west = lb; west <= ub; west++){ for(int south = lb; south <= ub; south++){ for(int east = lb; east <= ub; east++){ for(int north = lb; north <= ub; north++){ vi state = vi({here,west,south,east,north}); bool white_exists=state_contains(state, WHITE); bool yellow_exists=state_contains(state, YELLOW); bool purple_exists=state_contains(state, PURPLE); bool red_exists=state_contains(state, RED); bool orange_exists=state_contains(state, ORANGE); bool pink_exists=state_contains(state, PINK); bool is_start_cell = (state[LEFT]==state[UP] and state[LEFT]==BOUNDARY); bool is_end_cell = (state[DOWN]==state[RIGHT] and state[DOWN]==BOUNDARY); if(!yellow_exists and !orange_exists and !pink_exists){ // phase 1, get to final cell int x = findFirstNeighbour(state, WHITE, {RIGHT,DOWN}); if(x!=-1) Set(state,PURPLE,x); else{ if(!is_end_cell){ Set(state,RED,findFirstNeighbour(state,PURPLE)); } else{ // begin phase 2 Set(state,ORANGE,findFirstNeighbour(state,PURPLE)); } } } else{ if(!yellow_exists and !pink_exists){ // phase 2, get back to start cell if(!is_start_cell){ Set(state,ORANGE,findFirstNeighbour(state,PURPLE)); } else{ // begin phase 3 int deadEnd = findFirstNeighbour(state,RED); int orangeCell = findFirstNeighbour(state,ORANGE); if(deadEnd!=-1) Set(state,PINK,deadEnd); else Set(state,YELLOW,orangeCell); } } else{ // phase 3, color all obstacles to white, then color orange path to yellow if(!is_end_cell){ int deadEnd = findFirstNeighbour(state,RED, {RIGHT,DOWN}); int orangeCell = findFirstNeighbour(state,ORANGE); int pinkCell = findFirstNeighbour(state,PINK); int yellowCell = findFirstNeighbour(state,YELLOW); int x; bool is_pink_cell = state_contains(state,PINK,{0}); bool is_red_cell = state_contains(state,RED,{0}); if(is_pink_cell or is_red_cell){ if(deadEnd!=-1) Set(state,PINK,deadEnd); else{ if(pinkCell!=-1) Set(state, WHITE, pinkCell); else Set(state, YELLOW, orangeCell); } } else{ if(deadEnd!=-1) Set(state,PINK,deadEnd); else Set(state, YELLOW, orangeCell); } } else{ // we are done! Set(state,YELLOW,END); } } } } } } } } }
#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...