답안 #847492

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
847492 2023-09-09T18:18:14 Z emeraldblock 로봇 대회 (IOI23_robot) C++17
100 / 100
99 ms 6224 KB
#include "robot.h"
#include <bits/stdc++.h>

using namespace std;

enum Id {
    Bound = -2,
    Block,
    Empty,
    Path,
    West,
    South,
    East,
    North,
    Imp,
};
array<char,4> dirs{{'W','S','E','N'}};
pair<int,char> IMP = {Imp,'T'};

pair<int,char> move(array<int,5> S) {
    auto [h,w,s,e,n] = S;
    if (h == Empty) {
        if (w == Bound && n == Bound) {
            // start BFS phase
            if (s == Empty) {
                return {South,'S'};
            } else {
                return {East,'E'};
            }
        } else if (e == Bound && s == Bound) {
            // start pruning phase
            return {East,'H'};
        } else {
            // extend tree
            for (int i = 0; i < 4; ++i) {
                if (S[i+1]-West == (i+2)%4) return {West+i,dirs[i]};
            }
            return IMP;
        }
    } else if (0 <= h-West && h-West < 4) {
        int dir = h-West;
        if (S[dir+1]-West == (dir+2)%4) {
            // traverse tree
            int i = dir;
            do {
                i = (i+1)%4;
                if (S[i+1]-West == (i+2)%4 || S[i+1] == Empty) return {West+i,dirs[i]};
            } while (i != dir);
            return IMP;
        } else {
            // pruning phase
            int i = dir;
            bool path = false;
            do {
                i = (i+1)%4;
                // traverse to tile other than previous
                if (S[i+1]-West == (i+2)%4) return {h,dirs[i]};
                if (S[i+1] == Path) path = true;
            } while (i != dir);
            // prune
            return {
                path || (w == Bound && n == Bound) ? Path : Empty,
                e == Bound && s == Bound ? 'T' : dirs[i],
            };
        }
    } else {
        return IMP;
    }
}

#define FR(x) for (int x = Bound; x < Imp; ++x)

void program_pulibot()
{
    FR(h) FR(w) FR(s) FR(e) FR(n) {
        auto [Z,A] = move({h,w,s,e,n});
        if (Z > 5) continue;
        set_instruction({h,w,s,e,n}, Z, A);
    }
}
# 결과 실행 시간 메모리 Grader output
1 Correct 90 ms 5904 KB Output is correct
2 Correct 88 ms 5712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 5872 KB Output is correct
2 Correct 89 ms 5712 KB Output is correct
3 Correct 88 ms 5716 KB Output is correct
4 Correct 92 ms 5712 KB Output is correct
5 Correct 91 ms 5712 KB Output is correct
6 Correct 96 ms 5696 KB Output is correct
7 Correct 92 ms 5836 KB Output is correct
8 Correct 87 ms 5712 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 5872 KB Output is correct
2 Correct 89 ms 5712 KB Output is correct
3 Correct 88 ms 5716 KB Output is correct
4 Correct 92 ms 5712 KB Output is correct
5 Correct 91 ms 5712 KB Output is correct
6 Correct 88 ms 5712 KB Output is correct
7 Correct 94 ms 5712 KB Output is correct
8 Correct 91 ms 5712 KB Output is correct
9 Correct 89 ms 5712 KB Output is correct
10 Correct 88 ms 5800 KB Output is correct
11 Correct 88 ms 5712 KB Output is correct
12 Correct 89 ms 5712 KB Output is correct
13 Correct 91 ms 6000 KB Output is correct
14 Correct 90 ms 5712 KB Output is correct
15 Correct 88 ms 5708 KB Output is correct
16 Correct 88 ms 5712 KB Output is correct
17 Correct 92 ms 5712 KB Output is correct
18 Correct 91 ms 5712 KB Output is correct
19 Correct 89 ms 5712 KB Output is correct
20 Correct 89 ms 5840 KB Output is correct
21 Correct 89 ms 5712 KB Output is correct
22 Correct 99 ms 6032 KB Output is correct
23 Correct 88 ms 5764 KB Output is correct
24 Correct 89 ms 5972 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 92 ms 5884 KB Output is correct
2 Correct 89 ms 5928 KB Output is correct
3 Correct 88 ms 5712 KB Output is correct
4 Correct 92 ms 5716 KB Output is correct
5 Correct 98 ms 5796 KB Output is correct
6 Correct 91 ms 5712 KB Output is correct
7 Correct 96 ms 5712 KB Output is correct
8 Correct 88 ms 5712 KB Output is correct
9 Correct 89 ms 5712 KB Output is correct
10 Correct 88 ms 5824 KB Output is correct
11 Correct 90 ms 5716 KB Output is correct
12 Correct 89 ms 5708 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 88 ms 5872 KB Output is correct
2 Correct 89 ms 5712 KB Output is correct
3 Correct 88 ms 5716 KB Output is correct
4 Correct 92 ms 5712 KB Output is correct
5 Correct 91 ms 5712 KB Output is correct
6 Correct 96 ms 5696 KB Output is correct
7 Correct 92 ms 5836 KB Output is correct
8 Correct 87 ms 5712 KB Output is correct
9 Correct 88 ms 5712 KB Output is correct
10 Correct 92 ms 5712 KB Output is correct
11 Correct 91 ms 5712 KB Output is correct
12 Correct 89 ms 5712 KB Output is correct
13 Correct 89 ms 5840 KB Output is correct
14 Correct 89 ms 5712 KB Output is correct
15 Correct 99 ms 6032 KB Output is correct
16 Correct 88 ms 5764 KB Output is correct
17 Correct 89 ms 5972 KB Output is correct
18 Correct 92 ms 5704 KB Output is correct
19 Correct 90 ms 6096 KB Output is correct
20 Correct 96 ms 5932 KB Output is correct
21 Correct 92 ms 5712 KB Output is correct
22 Correct 92 ms 5848 KB Output is correct
23 Correct 95 ms 5832 KB Output is correct
24 Correct 88 ms 5928 KB Output is correct
25 Correct 89 ms 5712 KB Output is correct
26 Correct 88 ms 5968 KB Output is correct
27 Correct 88 ms 5876 KB Output is correct
28 Correct 93 ms 5744 KB Output is correct
29 Correct 89 ms 5924 KB Output is correct
30 Correct 95 ms 6004 KB Output is correct
31 Correct 91 ms 5844 KB Output is correct
32 Correct 89 ms 5712 KB Output is correct
33 Correct 90 ms 5684 KB Output is correct
34 Correct 93 ms 5716 KB Output is correct
35 Correct 90 ms 5920 KB Output is correct
36 Correct 90 ms 5712 KB Output is correct
37 Correct 88 ms 5716 KB Output is correct
38 Correct 88 ms 5872 KB Output is correct
39 Correct 90 ms 5684 KB Output is correct
40 Correct 94 ms 5976 KB Output is correct
41 Correct 90 ms 5876 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 94 ms 5860 KB Output is correct
2 Correct 91 ms 5716 KB Output is correct
3 Correct 89 ms 5716 KB Output is correct
4 Correct 88 ms 5972 KB Output is correct
5 Correct 89 ms 5720 KB Output is correct
6 Correct 91 ms 5732 KB Output is correct
7 Correct 88 ms 5768 KB Output is correct
8 Correct 89 ms 5752 KB Output is correct
9 Correct 90 ms 5888 KB Output is correct
10 Correct 89 ms 5848 KB Output is correct
11 Correct 88 ms 5908 KB Output is correct
12 Correct 92 ms 5716 KB Output is correct
13 Correct 88 ms 5712 KB Output is correct
14 Correct 93 ms 5968 KB Output is correct
15 Correct 88 ms 5712 KB Output is correct
16 Correct 91 ms 5712 KB Output is correct
17 Correct 90 ms 5776 KB Output is correct
18 Correct 88 ms 5716 KB Output is correct
19 Correct 92 ms 5884 KB Output is correct
20 Correct 89 ms 5720 KB Output is correct
21 Correct 89 ms 5816 KB Output is correct
22 Correct 91 ms 5712 KB Output is correct
23 Correct 88 ms 5904 KB Output is correct
24 Correct 98 ms 5812 KB Output is correct
25 Correct 91 ms 5856 KB Output is correct
26 Correct 88 ms 5688 KB Output is correct
27 Correct 91 ms 5712 KB Output is correct
28 Correct 88 ms 5708 KB Output is correct
29 Correct 93 ms 6060 KB Output is correct
30 Correct 88 ms 5828 KB Output is correct
31 Correct 88 ms 5852 KB Output is correct
32 Correct 90 ms 5688 KB Output is correct
33 Correct 90 ms 5792 KB Output is correct
34 Correct 88 ms 5712 KB Output is correct
35 Correct 91 ms 5712 KB Output is correct
36 Correct 89 ms 5928 KB Output is correct
37 Correct 90 ms 5712 KB Output is correct
38 Correct 89 ms 5872 KB Output is correct
39 Correct 88 ms 6224 KB Output is correct
40 Correct 90 ms 5972 KB Output is correct
41 Correct 89 ms 5712 KB Output is correct
42 Correct 95 ms 5944 KB Output is correct
43 Correct 92 ms 5712 KB Output is correct
44 Correct 90 ms 5716 KB Output is correct
45 Correct 88 ms 5712 KB Output is correct
46 Correct 90 ms 5896 KB Output is correct
47 Correct 91 ms 5828 KB Output is correct
48 Correct 89 ms 5744 KB Output is correct
49 Correct 90 ms 5712 KB Output is correct
50 Correct 88 ms 5744 KB Output is correct
51 Correct 91 ms 5868 KB Output is correct
52 Correct 92 ms 5824 KB Output is correct
53 Correct 91 ms 5712 KB Output is correct
54 Correct 94 ms 5784 KB Output is correct
55 Correct 88 ms 5712 KB Output is correct
56 Correct 88 ms 5764 KB Output is correct
57 Correct 89 ms 5828 KB Output is correct
58 Correct 91 ms 5852 KB Output is correct
59 Correct 91 ms 5712 KB Output is correct
60 Correct 95 ms 5800 KB Output is correct
61 Correct 92 ms 5712 KB Output is correct
62 Correct 90 ms 5712 KB Output is correct
63 Correct 90 ms 5712 KB Output is correct
64 Correct 88 ms 5716 KB Output is correct
65 Correct 91 ms 5736 KB Output is correct
66 Correct 87 ms 5908 KB Output is correct
67 Correct 89 ms 5712 KB Output is correct
68 Correct 88 ms 5712 KB Output is correct
69 Correct 88 ms 5852 KB Output is correct
70 Correct 92 ms 5796 KB Output is correct
71 Correct 90 ms 5712 KB Output is correct
72 Correct 93 ms 5856 KB Output is correct
73 Correct 89 ms 5808 KB Output is correct
74 Correct 88 ms 5852 KB Output is correct
75 Correct 95 ms 6108 KB Output is correct
76 Correct 91 ms 5712 KB Output is correct
77 Correct 89 ms 5764 KB Output is correct
78 Correct 88 ms 5760 KB Output is correct
79 Correct 90 ms 5712 KB Output is correct
80 Correct 91 ms 5716 KB Output is correct
81 Correct 91 ms 5716 KB Output is correct
82 Correct 90 ms 5968 KB Output is correct
83 Correct 94 ms 5712 KB Output is correct
84 Correct 93 ms 5832 KB Output is correct