Submission #1214055

#TimeUsernameProblemLanguageResultExecution timeMemory
1214055NeltRobot Contest (IOI23_robot)C++20
0 / 100
67 ms5960 KiB
#include "robot.h" #include <bits/stdc++.h> #pragma GCC optimize("O3") #define ll long long #define endl "\n" using namespace std; int H, W; // maze dimensions (provided by grader) int PHASE = 0; // 0 = BFS expansion, 1 = traceback int L = 0; // current BFS layer int C = 2; // marker color = L%4 + 2 void program_pulibot() { vector<int> V = { -2, -1, 0, 1, 2, 3, 4, 5 }; vector<int> S(5); auto mv = [&](int c) -> char { if (c == 2) return 'W'; if (c == 3) return 'S'; if (c == 4) return 'E'; return 'N'; }; for (int s0 : V) for (int s1 : V) for (int s2 : V) for (int s3 : V) for (int s4 : V) { S[0] = s0; S[1] = s1; S[2] = s2; S[3] = s3; S[4] = s4; if (PHASE == 0) { // --- BFS expansion phase --- // 1) if on an unvisited cell at current layer, mark its parent pointer if (s0 == 0 && s1 == C) { bool moved = false; for (int d = 0; d < 4; d++) { if (S[d+2] == 0) // neighbor unvisited { int code = C + (d%4); set_instruction(S, code, mv(code)); moved = true; break; } } if (moved) continue; } // 2) detect first arrival at goal → switch to traceback if (s0 == 0 && s2 == -2 && s3 == -2) { PHASE = 1; set_instruction(S, 1, 'T'); continue; } // 3) after sweeping all of layer L, advance to next layer // (we see no S[1]==C anymore) bool any_at_layer = false; for (int x : V) if (x == C) { any_at_layer = true; break; } if (!any_at_layer) { L++; C = 2 + (L % 4); } // 4) on all other states, stay put set_instruction(S, 0, 'H'); } else { // --- traceback phase --- if (s0 >= 2 && s0 <= 5) { set_instruction(S, 1, mv(s0)); } else { set_instruction(S, 0, 'H'); } } } }
#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...