Submission #843625

#TimeUsernameProblemLanguageResultExecution timeMemory
843625TranGiaHuy1508Robot Contest (IOI23_robot)C++17
16 / 100
99 ms7416 KiB
#include <bits/stdc++.h> using namespace std; #include "robot.h" enum State { BOUNDARY = -2, OBSTACLE = -1, EMPTY = 0, MAIN = 1, WEST = 2, SOUTH = 3, EAST = 4, NORTH = 5, EVERYTHING = -42, BLOCKED = -3, }; enum Move { M_STAY = 'H', M_WEST = 'W', M_SOUTH = 'S', M_EAST = 'E', M_NORTH = 'N', M_TERMINATE = 'T', }; namespace Script { static const int arrLen = 5; using StateArray = array<State, arrLen>; using Instruction = pair<State, Move>; map<StateArray, Instruction> mp; // Helper functions vector<State> group(State S){ if (S == BLOCKED) return {BOUNDARY, OBSTACLE}; if (S == EVERYTHING) return { BOUNDARY, OBSTACLE, EMPTY, MAIN, WEST, SOUTH, EAST, NORTH }; return {S}; } template <bool OVERWRITE = false> void program(StateArray S, Instruction I){ vector<StateArray> arrs = {StateArray()}; // Construct all possible StateArray(s) for (int i = 0; i < arrLen; i++){ vector<StateArray> new_arrs; vector<State> repr = group(S[i]); for (auto arr: arrs){ for (auto j: repr){ new_arrs.push_back(arr); new_arrs.back()[i] = j; } } new_arrs.swap(arrs); } // Resolve for (auto arr: arrs){ if (!OVERWRITE && mp.count(arr)) continue; mp[arr] = I; } } template <bool OVERWRITE = false> void program(StateArray S, State Z, Move A){ return program<OVERWRITE>(S, {Z, A}); } void set_all_instruction(){ for (auto [S, I]: mp){ vector<int> vS(begin(S), begin(S) + arrLen); set_instruction(vS, I.first, I.second); } } } void main_program(); void program_pulibot(){ main_program(); Script::set_all_instruction(); } void main_program(){ Script::program<false>({ EVERYTHING, EVERYTHING, EVERYTHING, EMPTY, EVERYTHING }, MAIN, M_EAST); Script::program<false>({ EVERYTHING, EVERYTHING, EMPTY, EVERYTHING, EVERYTHING }, MAIN, M_SOUTH); Script::program<false>({ EVERYTHING, EVERYTHING, EVERYTHING, EVERYTHING, EMPTY }, MAIN, M_NORTH); Script::program<true>({ EVERYTHING, EVERYTHING, BOUNDARY, BOUNDARY, EVERYTHING }, MAIN, M_TERMINATE); }
#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...