제출 #843241

#제출 시각아이디문제언어결과실행 시간메모리
843241SHZhang로봇 대회 (IOI23_robot)C++17
63 / 100
135 ms6388 KiB
#include "robot.h" const char* direction = "WSENH"; const int blank = 0; const int chain = 1; const int left = 2; const int down = 3; const int right = 4; const int up = 5; const int complete = 6; void program_pulibot() { for (int s2 = -2; s2 <= 6; s2++) { for (int s3 = -2; s3 <= 6; s3++) { for (int s4 = -2; s4 <= 6; s4++) { for (int s5 = -2; s5 <= 6; s5++) { bool is_root = (s2 == -2 && s5 == -2); bool is_end = (s3 == -2 && s4 == -2); int dirstates[4] = {s2, s3, s4, s5}; set_instruction({blank, s2, s3, s4, s5}, chain, 'H'); int childidx = 4; int parentidx = 4; for (int i = 0; i < 4; i++) { if (dirstates[i] == blank || (i == 0 && dirstates[i] == right) || (i == 1 && dirstates[i] == up) || (i == 2 && dirstates[i] == left) || (i == 3 && dirstates[i] == down)) { childidx = i; break; } } for (int i = 0; i < 4; i++) { if (dirstates[i] == chain || dirstates[i] == complete) { parentidx = i; } } for (int i = left; i <= up; i++) { set_instruction({i, s2, s3, s4, s5}, chain, direction[childidx]); } set_instruction({complete, s2, s3, s4, s5}, (parentidx == 4 ? chain : parentidx + 2), direction[parentidx]); int chaincnt = 0, compcnt = 0; for (int i = 0; i < 4; i++) { if (dirstates[i] == chain) chaincnt++; if (dirstates[i] == complete) compcnt++; } if (is_end) { set_instruction({chain, s2, s3, s4, s5}, chain, 'T'); } else if (chaincnt <= 1 && compcnt == 0 && !is_root) { set_instruction({chain, s2, s3, s4, s5}, complete, direction[parentidx]); } else { bool child_before_complete = false; for (int i = childidx + 1; i < 4; i++) { if (dirstates[i] == complete) child_before_complete = true; } if (child_before_complete || childidx == 4) { bool done = false; for (int i = 0; i < 4; i++) { if (dirstates[i] == complete) { set_instruction({chain, s2, s3, s4, s5}, chain, direction[i]); done = true; break; } } if (!done) { set_instruction({chain, s2, s3, s4, s5}, complete, direction[parentidx]); } } else { set_instruction({chain, s2, s3, s4, s5}, chain, direction[childidx]); } } } } } } }
#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...