답안 #737654

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
737654 2023-05-07T13:26:32 Z Abrar_Al_Samit 벽 칠하기 (APIO20_paint) C++17
51 / 100
462 ms 147400 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;



const int nax = 1e5;
const int snax = 1e4;


vector<int> col_to_wall[nax], cand[nax];
vector<bitset<snax>>is(nax/2);
bool good[nax];
bool on[nax];

int minimumInstructions(
    int N, int M, int K, vector<int> C,
    vector<int> A, vector<vector<int>> B) {

    
    for(int i=0; i<N; ++i) {
        col_to_wall[C[i]].push_back(i);
    }

    for(int i=0; i<M; ++i) {
        for(int j=0; j<A[i]; ++j) {
            for(int x : col_to_wall[B[i][j]]) {
                cand[x].push_back(i);
                is[x][i] = 1;
            }
        }
    }

    int prev_succ = -1;
    for(int i=0; i<=N-M; ++i) {
        int cur_succ = -1;
        for(int j : cand[i]) {

            int pre_tag = (j-1+M)%M;
            bool yasss = true;


            if(pre_tag==prev_succ) {
                if(i+M-1<snax) {
                    if(is[i+M-1][pre_tag]) {
                        cur_succ = j;
                        break;
                    } else continue;
                } else {
                    if(binary_search(cand[i+M-1].begin(), cand[i+M-1].end(), pre_tag)) {
                        cur_succ = j;
                        break;
                    } else continue;
                }
            } else if(on[pre_tag]) {
                continue;
            }

            for(int l=1, cr=j+1; l<M; ++l, ++cr) {
                if(cr==M) cr = 0;

                if(i+l<snax) yasss &= is[i+l][cr];
                else yasss &= binary_search(cand[i+l].begin(), cand[i+l].end(), cr);

                if(!yasss) break;
            }
            if(yasss) {
                cur_succ = j;
                break;
            }
        }
        if(i) {
            for(int x : cand[i-1]) {
                if(x==prev_succ) break;
                on[x] = 0;
            }
        }
        for(int x : cand[i]) {
            if(x==cur_succ) break;
            on[x] = 1;
        }

        prev_succ = cur_succ;
        if(cur_succ!=-1) {
            good[i] = 1;
        }
    }


    if(!good[0]) return -1;
    int last = 0, pending = -1;

    int ans = 1;
    for(int i=1; i<N; ++i) {
        if(good[i]) {
            pending = i;
        }
        if(last+M==i) {
            if(pending==-1) return -1;
            last = pending;
            pending = -1;
            ++ans;
        }
    }
    return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 66424 KB Output is correct
2 Correct 26 ms 66400 KB Output is correct
3 Correct 29 ms 66380 KB Output is correct
4 Correct 30 ms 66440 KB Output is correct
5 Correct 29 ms 66388 KB Output is correct
6 Correct 27 ms 66324 KB Output is correct
7 Correct 27 ms 66424 KB Output is correct
8 Correct 30 ms 66388 KB Output is correct
9 Correct 28 ms 66380 KB Output is correct
10 Correct 26 ms 66436 KB Output is correct
11 Correct 27 ms 66444 KB Output is correct
12 Correct 29 ms 66444 KB Output is correct
13 Correct 29 ms 66404 KB Output is correct
14 Correct 27 ms 66516 KB Output is correct
15 Correct 27 ms 66512 KB Output is correct
16 Correct 28 ms 66380 KB Output is correct
17 Correct 30 ms 66388 KB Output is correct
18 Correct 28 ms 66484 KB Output is correct
19 Correct 28 ms 66432 KB Output is correct
20 Correct 27 ms 66484 KB Output is correct
21 Correct 29 ms 66532 KB Output is correct
22 Correct 36 ms 67256 KB Output is correct
23 Correct 36 ms 67268 KB Output is correct
24 Correct 37 ms 67164 KB Output is correct
25 Correct 31 ms 67316 KB Output is correct
26 Correct 33 ms 67276 KB Output is correct
27 Correct 32 ms 67228 KB Output is correct
28 Correct 33 ms 67276 KB Output is correct
29 Correct 32 ms 67328 KB Output is correct
30 Correct 32 ms 67252 KB Output is correct
31 Correct 38 ms 68164 KB Output is correct
32 Correct 39 ms 68104 KB Output is correct
33 Correct 37 ms 68076 KB Output is correct
34 Correct 38 ms 68156 KB Output is correct
35 Correct 39 ms 68172 KB Output is correct
36 Correct 42 ms 68184 KB Output is correct
37 Correct 46 ms 68692 KB Output is correct
38 Correct 45 ms 68616 KB Output is correct
39 Correct 50 ms 68648 KB Output is correct
40 Runtime error 100 ms 139792 KB Execution killed with signal 11
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 27 ms 66424 KB Output is correct
2 Correct 26 ms 66400 KB Output is correct
3 Correct 29 ms 66380 KB Output is correct
4 Correct 30 ms 66440 KB Output is correct
5 Correct 29 ms 66388 KB Output is correct
6 Correct 27 ms 66324 KB Output is correct
7 Correct 27 ms 66424 KB Output is correct
8 Correct 30 ms 66388 KB Output is correct
9 Correct 28 ms 66380 KB Output is correct
10 Correct 26 ms 66436 KB Output is correct
11 Correct 27 ms 66444 KB Output is correct
12 Correct 29 ms 66444 KB Output is correct
13 Correct 29 ms 66404 KB Output is correct
14 Correct 27 ms 66516 KB Output is correct
15 Correct 27 ms 66512 KB Output is correct
16 Correct 28 ms 66380 KB Output is correct
17 Correct 30 ms 66388 KB Output is correct
18 Correct 28 ms 66484 KB Output is correct
19 Correct 28 ms 66432 KB Output is correct
20 Correct 27 ms 66484 KB Output is correct
21 Correct 29 ms 66532 KB Output is correct
22 Correct 29 ms 66424 KB Output is correct
23 Correct 29 ms 66388 KB Output is correct
24 Correct 30 ms 66372 KB Output is correct
25 Correct 30 ms 66336 KB Output is correct
26 Correct 32 ms 66380 KB Output is correct
27 Correct 30 ms 66384 KB Output is correct
28 Correct 28 ms 66452 KB Output is correct
29 Correct 29 ms 66420 KB Output is correct
30 Correct 30 ms 66416 KB Output is correct
31 Correct 29 ms 66580 KB Output is correct
32 Correct 32 ms 66408 KB Output is correct
33 Correct 28 ms 66512 KB Output is correct
34 Correct 29 ms 66444 KB Output is correct
35 Correct 29 ms 66388 KB Output is correct
36 Correct 28 ms 66384 KB Output is correct
37 Correct 28 ms 66368 KB Output is correct
38 Correct 29 ms 66484 KB Output is correct
39 Correct 28 ms 66388 KB Output is correct
40 Correct 28 ms 66388 KB Output is correct
41 Correct 27 ms 66380 KB Output is correct
42 Correct 28 ms 66376 KB Output is correct
43 Correct 28 ms 66472 KB Output is correct
44 Correct 27 ms 66388 KB Output is correct
45 Correct 28 ms 66516 KB Output is correct
46 Correct 30 ms 66644 KB Output is correct
47 Correct 28 ms 66476 KB Output is correct
48 Correct 28 ms 66428 KB Output is correct
49 Correct 31 ms 66524 KB Output is correct
50 Correct 28 ms 66508 KB Output is correct
51 Correct 28 ms 66424 KB Output is correct
52 Correct 28 ms 66484 KB Output is correct
53 Correct 31 ms 66420 KB Output is correct
54 Correct 33 ms 66388 KB Output is correct
55 Correct 28 ms 66516 KB Output is correct
56 Correct 28 ms 66388 KB Output is correct
57 Correct 28 ms 66504 KB Output is correct
58 Correct 30 ms 66456 KB Output is correct
59 Correct 31 ms 66380 KB Output is correct
60 Correct 28 ms 66448 KB Output is correct
61 Correct 28 ms 66516 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 66424 KB Output is correct
2 Correct 29 ms 66388 KB Output is correct
3 Correct 27 ms 66424 KB Output is correct
4 Correct 26 ms 66400 KB Output is correct
5 Correct 29 ms 66380 KB Output is correct
6 Correct 30 ms 66440 KB Output is correct
7 Correct 29 ms 66388 KB Output is correct
8 Correct 27 ms 66324 KB Output is correct
9 Correct 27 ms 66424 KB Output is correct
10 Correct 30 ms 66388 KB Output is correct
11 Correct 28 ms 66380 KB Output is correct
12 Correct 26 ms 66436 KB Output is correct
13 Correct 27 ms 66444 KB Output is correct
14 Correct 29 ms 66444 KB Output is correct
15 Correct 29 ms 66404 KB Output is correct
16 Correct 27 ms 66516 KB Output is correct
17 Correct 27 ms 66512 KB Output is correct
18 Correct 28 ms 66380 KB Output is correct
19 Correct 30 ms 66388 KB Output is correct
20 Correct 28 ms 66484 KB Output is correct
21 Correct 28 ms 66432 KB Output is correct
22 Correct 27 ms 66484 KB Output is correct
23 Correct 29 ms 66532 KB Output is correct
24 Correct 36 ms 67256 KB Output is correct
25 Correct 36 ms 67268 KB Output is correct
26 Correct 37 ms 67164 KB Output is correct
27 Correct 30 ms 66372 KB Output is correct
28 Correct 30 ms 66336 KB Output is correct
29 Correct 32 ms 66380 KB Output is correct
30 Correct 30 ms 66384 KB Output is correct
31 Correct 28 ms 66452 KB Output is correct
32 Correct 29 ms 66420 KB Output is correct
33 Correct 30 ms 66416 KB Output is correct
34 Correct 29 ms 66580 KB Output is correct
35 Correct 32 ms 66408 KB Output is correct
36 Correct 28 ms 66512 KB Output is correct
37 Correct 29 ms 66444 KB Output is correct
38 Correct 29 ms 66388 KB Output is correct
39 Correct 28 ms 66384 KB Output is correct
40 Correct 28 ms 66368 KB Output is correct
41 Correct 29 ms 66484 KB Output is correct
42 Correct 28 ms 66388 KB Output is correct
43 Correct 28 ms 66388 KB Output is correct
44 Correct 27 ms 66380 KB Output is correct
45 Correct 28 ms 66376 KB Output is correct
46 Correct 28 ms 66472 KB Output is correct
47 Correct 27 ms 66388 KB Output is correct
48 Correct 28 ms 66516 KB Output is correct
49 Correct 30 ms 66644 KB Output is correct
50 Correct 28 ms 66476 KB Output is correct
51 Correct 28 ms 66428 KB Output is correct
52 Correct 31 ms 66524 KB Output is correct
53 Correct 28 ms 66508 KB Output is correct
54 Correct 28 ms 66424 KB Output is correct
55 Correct 28 ms 66484 KB Output is correct
56 Correct 31 ms 66420 KB Output is correct
57 Correct 33 ms 66388 KB Output is correct
58 Correct 28 ms 66516 KB Output is correct
59 Correct 28 ms 66388 KB Output is correct
60 Correct 28 ms 66504 KB Output is correct
61 Correct 30 ms 66456 KB Output is correct
62 Correct 31 ms 66380 KB Output is correct
63 Correct 28 ms 66448 KB Output is correct
64 Correct 28 ms 66516 KB Output is correct
65 Correct 33 ms 66692 KB Output is correct
66 Correct 28 ms 66544 KB Output is correct
67 Correct 30 ms 66636 KB Output is correct
68 Correct 31 ms 66632 KB Output is correct
69 Correct 30 ms 66708 KB Output is correct
70 Correct 29 ms 66596 KB Output is correct
71 Correct 30 ms 66536 KB Output is correct
72 Correct 29 ms 66572 KB Output is correct
73 Correct 28 ms 66444 KB Output is correct
74 Correct 30 ms 66572 KB Output is correct
75 Correct 31 ms 66640 KB Output is correct
76 Correct 39 ms 67248 KB Output is correct
77 Correct 47 ms 67324 KB Output is correct
78 Correct 45 ms 67584 KB Output is correct
79 Correct 34 ms 66932 KB Output is correct
80 Correct 34 ms 66888 KB Output is correct
81 Correct 31 ms 67004 KB Output is correct
82 Correct 30 ms 66932 KB Output is correct
83 Correct 30 ms 66900 KB Output is correct
84 Correct 31 ms 66660 KB Output is correct
85 Correct 31 ms 66700 KB Output is correct
86 Correct 31 ms 66616 KB Output is correct
87 Correct 32 ms 66644 KB Output is correct
88 Correct 30 ms 66704 KB Output is correct
89 Correct 30 ms 66600 KB Output is correct
90 Correct 47 ms 67680 KB Output is correct
91 Correct 44 ms 67708 KB Output is correct
92 Correct 45 ms 67660 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 66424 KB Output is correct
2 Correct 29 ms 66388 KB Output is correct
3 Correct 27 ms 66424 KB Output is correct
4 Correct 26 ms 66400 KB Output is correct
5 Correct 29 ms 66380 KB Output is correct
6 Correct 30 ms 66440 KB Output is correct
7 Correct 29 ms 66388 KB Output is correct
8 Correct 27 ms 66324 KB Output is correct
9 Correct 27 ms 66424 KB Output is correct
10 Correct 30 ms 66388 KB Output is correct
11 Correct 28 ms 66380 KB Output is correct
12 Correct 26 ms 66436 KB Output is correct
13 Correct 27 ms 66444 KB Output is correct
14 Correct 29 ms 66444 KB Output is correct
15 Correct 29 ms 66404 KB Output is correct
16 Correct 27 ms 66516 KB Output is correct
17 Correct 27 ms 66512 KB Output is correct
18 Correct 28 ms 66380 KB Output is correct
19 Correct 30 ms 66388 KB Output is correct
20 Correct 28 ms 66484 KB Output is correct
21 Correct 28 ms 66432 KB Output is correct
22 Correct 27 ms 66484 KB Output is correct
23 Correct 29 ms 66532 KB Output is correct
24 Correct 36 ms 67256 KB Output is correct
25 Correct 36 ms 67268 KB Output is correct
26 Correct 37 ms 67164 KB Output is correct
27 Correct 31 ms 67316 KB Output is correct
28 Correct 33 ms 67276 KB Output is correct
29 Correct 32 ms 67228 KB Output is correct
30 Correct 33 ms 67276 KB Output is correct
31 Correct 32 ms 67328 KB Output is correct
32 Correct 32 ms 67252 KB Output is correct
33 Correct 38 ms 68164 KB Output is correct
34 Correct 39 ms 68104 KB Output is correct
35 Correct 37 ms 68076 KB Output is correct
36 Correct 38 ms 68156 KB Output is correct
37 Correct 39 ms 68172 KB Output is correct
38 Correct 42 ms 68184 KB Output is correct
39 Correct 46 ms 68692 KB Output is correct
40 Correct 45 ms 68616 KB Output is correct
41 Correct 50 ms 68648 KB Output is correct
42 Correct 30 ms 66372 KB Output is correct
43 Correct 30 ms 66336 KB Output is correct
44 Correct 32 ms 66380 KB Output is correct
45 Correct 30 ms 66384 KB Output is correct
46 Correct 28 ms 66452 KB Output is correct
47 Correct 29 ms 66420 KB Output is correct
48 Correct 30 ms 66416 KB Output is correct
49 Correct 29 ms 66580 KB Output is correct
50 Correct 32 ms 66408 KB Output is correct
51 Correct 28 ms 66512 KB Output is correct
52 Correct 29 ms 66444 KB Output is correct
53 Correct 29 ms 66388 KB Output is correct
54 Correct 28 ms 66384 KB Output is correct
55 Correct 28 ms 66368 KB Output is correct
56 Correct 29 ms 66484 KB Output is correct
57 Correct 28 ms 66388 KB Output is correct
58 Correct 28 ms 66388 KB Output is correct
59 Correct 27 ms 66380 KB Output is correct
60 Correct 28 ms 66376 KB Output is correct
61 Correct 28 ms 66472 KB Output is correct
62 Correct 27 ms 66388 KB Output is correct
63 Correct 28 ms 66516 KB Output is correct
64 Correct 30 ms 66644 KB Output is correct
65 Correct 28 ms 66476 KB Output is correct
66 Correct 28 ms 66428 KB Output is correct
67 Correct 31 ms 66524 KB Output is correct
68 Correct 28 ms 66508 KB Output is correct
69 Correct 28 ms 66424 KB Output is correct
70 Correct 28 ms 66484 KB Output is correct
71 Correct 31 ms 66420 KB Output is correct
72 Correct 33 ms 66388 KB Output is correct
73 Correct 28 ms 66516 KB Output is correct
74 Correct 28 ms 66388 KB Output is correct
75 Correct 28 ms 66504 KB Output is correct
76 Correct 30 ms 66456 KB Output is correct
77 Correct 31 ms 66380 KB Output is correct
78 Correct 28 ms 66448 KB Output is correct
79 Correct 28 ms 66516 KB Output is correct
80 Correct 33 ms 66692 KB Output is correct
81 Correct 28 ms 66544 KB Output is correct
82 Correct 30 ms 66636 KB Output is correct
83 Correct 31 ms 66632 KB Output is correct
84 Correct 30 ms 66708 KB Output is correct
85 Correct 29 ms 66596 KB Output is correct
86 Correct 30 ms 66536 KB Output is correct
87 Correct 29 ms 66572 KB Output is correct
88 Correct 28 ms 66444 KB Output is correct
89 Correct 30 ms 66572 KB Output is correct
90 Correct 31 ms 66640 KB Output is correct
91 Correct 39 ms 67248 KB Output is correct
92 Correct 47 ms 67324 KB Output is correct
93 Correct 45 ms 67584 KB Output is correct
94 Correct 34 ms 66932 KB Output is correct
95 Correct 34 ms 66888 KB Output is correct
96 Correct 31 ms 67004 KB Output is correct
97 Correct 30 ms 66932 KB Output is correct
98 Correct 30 ms 66900 KB Output is correct
99 Correct 31 ms 66660 KB Output is correct
100 Correct 31 ms 66700 KB Output is correct
101 Correct 31 ms 66616 KB Output is correct
102 Correct 32 ms 66644 KB Output is correct
103 Correct 30 ms 66704 KB Output is correct
104 Correct 30 ms 66600 KB Output is correct
105 Correct 47 ms 67680 KB Output is correct
106 Correct 44 ms 67708 KB Output is correct
107 Correct 45 ms 67660 KB Output is correct
108 Correct 33 ms 67276 KB Output is correct
109 Correct 264 ms 125212 KB Output is correct
110 Correct 209 ms 91568 KB Output is correct
111 Correct 172 ms 90004 KB Output is correct
112 Correct 225 ms 97856 KB Output is correct
113 Correct 118 ms 81996 KB Output is correct
114 Correct 48 ms 68176 KB Output is correct
115 Correct 44 ms 67884 KB Output is correct
116 Correct 50 ms 68320 KB Output is correct
117 Correct 46 ms 67976 KB Output is correct
118 Correct 45 ms 68152 KB Output is correct
119 Correct 42 ms 67904 KB Output is correct
120 Correct 48 ms 67992 KB Output is correct
121 Correct 44 ms 67356 KB Output is correct
122 Correct 48 ms 68044 KB Output is correct
123 Correct 36 ms 67212 KB Output is correct
124 Correct 50 ms 68492 KB Output is correct
125 Correct 39 ms 67656 KB Output is correct
126 Correct 39 ms 67688 KB Output is correct
127 Correct 41 ms 67984 KB Output is correct
128 Correct 37 ms 67540 KB Output is correct
129 Correct 37 ms 67532 KB Output is correct
130 Correct 34 ms 67328 KB Output is correct
131 Correct 437 ms 147400 KB Output is correct
132 Correct 462 ms 107208 KB Output is correct
133 Correct 410 ms 107272 KB Output is correct
134 Correct 348 ms 107348 KB Output is correct
135 Correct 310 ms 103236 KB Output is correct
136 Correct 50 ms 68644 KB Output is correct
137 Correct 50 ms 68556 KB Output is correct
138 Correct 55 ms 68600 KB Output is correct
139 Correct 49 ms 68600 KB Output is correct
140 Correct 47 ms 68628 KB Output is correct
141 Correct 46 ms 68560 KB Output is correct
142 Correct 58 ms 68984 KB Output is correct
143 Correct 39 ms 67828 KB Output is correct
144 Correct 62 ms 69032 KB Output is correct
145 Correct 42 ms 67924 KB Output is correct
146 Correct 54 ms 68984 KB Output is correct
147 Correct 39 ms 67952 KB Output is correct
148 Correct 40 ms 68220 KB Output is correct
149 Correct 39 ms 68188 KB Output is correct
150 Correct 47 ms 68040 KB Output is correct
151 Correct 39 ms 68044 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 29 ms 66424 KB Output is correct
2 Correct 29 ms 66388 KB Output is correct
3 Correct 27 ms 66424 KB Output is correct
4 Correct 26 ms 66400 KB Output is correct
5 Correct 29 ms 66380 KB Output is correct
6 Correct 30 ms 66440 KB Output is correct
7 Correct 29 ms 66388 KB Output is correct
8 Correct 27 ms 66324 KB Output is correct
9 Correct 27 ms 66424 KB Output is correct
10 Correct 30 ms 66388 KB Output is correct
11 Correct 28 ms 66380 KB Output is correct
12 Correct 26 ms 66436 KB Output is correct
13 Correct 27 ms 66444 KB Output is correct
14 Correct 29 ms 66444 KB Output is correct
15 Correct 29 ms 66404 KB Output is correct
16 Correct 27 ms 66516 KB Output is correct
17 Correct 27 ms 66512 KB Output is correct
18 Correct 28 ms 66380 KB Output is correct
19 Correct 30 ms 66388 KB Output is correct
20 Correct 28 ms 66484 KB Output is correct
21 Correct 28 ms 66432 KB Output is correct
22 Correct 27 ms 66484 KB Output is correct
23 Correct 29 ms 66532 KB Output is correct
24 Correct 36 ms 67256 KB Output is correct
25 Correct 36 ms 67268 KB Output is correct
26 Correct 37 ms 67164 KB Output is correct
27 Correct 31 ms 67316 KB Output is correct
28 Correct 33 ms 67276 KB Output is correct
29 Correct 32 ms 67228 KB Output is correct
30 Correct 33 ms 67276 KB Output is correct
31 Correct 32 ms 67328 KB Output is correct
32 Correct 32 ms 67252 KB Output is correct
33 Correct 38 ms 68164 KB Output is correct
34 Correct 39 ms 68104 KB Output is correct
35 Correct 37 ms 68076 KB Output is correct
36 Correct 38 ms 68156 KB Output is correct
37 Correct 39 ms 68172 KB Output is correct
38 Correct 42 ms 68184 KB Output is correct
39 Correct 46 ms 68692 KB Output is correct
40 Correct 45 ms 68616 KB Output is correct
41 Correct 50 ms 68648 KB Output is correct
42 Runtime error 100 ms 139792 KB Execution killed with signal 11
43 Halted 0 ms 0 KB -