답안 #410345

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
410345 2021-05-22T14:28:05 Z Carmel_Ab1 벽 칠하기 (APIO20_paint) C++17
51 / 100
1247 ms 524292 KB
#include <bits/stdc++.h>
#include "paint.h"

//#include "grader.cpp"

using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define all(x) x.begin(),x.end()
#define pb push_back
int minimumInstructions(int N, int M, int K, vi C,vi A, vvi B) {

    for(int i=0; i<B.size(); i++)
        sort(all(B[i]));
    vvi can(N,vi(M));// iff a sequence from j can start in i

    for(int j=0; j<M; j++){
        can[N-M][j]=0;
        for(int j2=0; j2<M;can[N-M][j]++,j2++)
            if(!binary_search(all(B[(j+j2)%M]),C[(N-M+j2)]))
                break;
    }
    for(int i=N-M-1; 0<=i;i--){
        for(int j=0; j<M; j++){
            if(!binary_search(all(B[j]),C[i]))continue;

            can[i][j]=min(M,can[i+1][(j+1)%M]+1);
        }
    }
    set<int>segs;
    for(int i=0; i<N; i++)
        for(int j=0; j<M; j++)
            if(can[i][j]==M)
                segs.insert(i);

    int ans=0;
    vector<bool>cov(N);

    for(int i=0; i<N;i++){
        if(cov[i])continue;
        int l=-1;
        for(int j=0;i-j>=0 && j<M; j++)
            if(segs.count(i-j)) {
                l = i - j;
                break;
            }
        if(l==-1)return -1;
        for(int j=l; j<l+M; j++)
            cov[j]=1;
        ans++;
    }
    return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, vi, vi, vvi)':
paint.cpp:14:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   14 |     for(int i=0; i<B.size(); i++)
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 352 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 716 KB Output is correct
14 Correct 3 ms 716 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
16 Correct 2 ms 716 KB Output is correct
17 Correct 2 ms 648 KB Output is correct
18 Correct 2 ms 716 KB Output is correct
19 Correct 3 ms 716 KB Output is correct
20 Correct 3 ms 656 KB Output is correct
21 Correct 3 ms 716 KB Output is correct
22 Correct 16 ms 1504 KB Output is correct
23 Correct 16 ms 1456 KB Output is correct
24 Correct 16 ms 1380 KB Output is correct
25 Correct 11 ms 2380 KB Output is correct
26 Correct 10 ms 2380 KB Output is correct
27 Correct 10 ms 1996 KB Output is correct
28 Correct 5 ms 1612 KB Output is correct
29 Correct 5 ms 1484 KB Output is correct
30 Correct 5 ms 1484 KB Output is correct
31 Correct 690 ms 158968 KB Output is correct
32 Correct 693 ms 159056 KB Output is correct
33 Correct 691 ms 159088 KB Output is correct
34 Correct 725 ms 159088 KB Output is correct
35 Correct 700 ms 159092 KB Output is correct
36 Correct 713 ms 159124 KB Output is correct
37 Correct 1061 ms 159432 KB Output is correct
38 Correct 1076 ms 159432 KB Output is correct
39 Correct 1064 ms 159428 KB Output is correct
40 Correct 47 ms 10320 KB Output is correct
41 Correct 31 ms 6600 KB Output is correct
42 Correct 31 ms 8932 KB Output is correct
43 Correct 17 ms 4784 KB Output is correct
44 Correct 13 ms 4140 KB Output is correct
45 Correct 22 ms 6644 KB Output is correct
46 Runtime error 271 ms 524292 KB Execution killed with signal 9
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 2 ms 352 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 204 KB Output is correct
11 Correct 1 ms 204 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 2 ms 716 KB Output is correct
14 Correct 3 ms 716 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
16 Correct 2 ms 716 KB Output is correct
17 Correct 2 ms 648 KB Output is correct
18 Correct 2 ms 716 KB Output is correct
19 Correct 3 ms 716 KB Output is correct
20 Correct 3 ms 656 KB Output is correct
21 Correct 3 ms 716 KB Output is correct
22 Correct 1 ms 204 KB Output is correct
23 Correct 1 ms 204 KB Output is correct
24 Correct 1 ms 204 KB Output is correct
25 Correct 1 ms 204 KB Output is correct
26 Correct 1 ms 204 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 332 KB Output is correct
29 Correct 1 ms 332 KB Output is correct
30 Correct 1 ms 332 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 588 KB Output is correct
34 Correct 2 ms 588 KB Output is correct
35 Correct 1 ms 460 KB Output is correct
36 Correct 1 ms 460 KB Output is correct
37 Correct 1 ms 460 KB Output is correct
38 Correct 1 ms 204 KB Output is correct
39 Correct 1 ms 204 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 460 KB Output is correct
42 Correct 2 ms 460 KB Output is correct
43 Correct 2 ms 332 KB Output is correct
44 Correct 1 ms 332 KB Output is correct
45 Correct 1 ms 332 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 2 ms 716 KB Output is correct
51 Correct 2 ms 716 KB Output is correct
52 Correct 2 ms 680 KB Output is correct
53 Correct 2 ms 716 KB Output is correct
54 Correct 2 ms 716 KB Output is correct
55 Correct 2 ms 716 KB Output is correct
56 Correct 2 ms 716 KB Output is correct
57 Correct 2 ms 716 KB Output is correct
58 Correct 2 ms 716 KB Output is correct
59 Correct 2 ms 716 KB Output is correct
60 Correct 2 ms 716 KB Output is correct
61 Correct 2 ms 716 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 352 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
16 Correct 3 ms 716 KB Output is correct
17 Correct 2 ms 716 KB Output is correct
18 Correct 2 ms 716 KB Output is correct
19 Correct 2 ms 648 KB Output is correct
20 Correct 2 ms 716 KB Output is correct
21 Correct 3 ms 716 KB Output is correct
22 Correct 3 ms 656 KB Output is correct
23 Correct 3 ms 716 KB Output is correct
24 Correct 16 ms 1504 KB Output is correct
25 Correct 16 ms 1456 KB Output is correct
26 Correct 16 ms 1380 KB Output is correct
27 Correct 1 ms 204 KB Output is correct
28 Correct 1 ms 204 KB Output is correct
29 Correct 1 ms 204 KB Output is correct
30 Correct 1 ms 204 KB Output is correct
31 Correct 1 ms 332 KB Output is correct
32 Correct 1 ms 332 KB Output is correct
33 Correct 1 ms 332 KB Output is correct
34 Correct 1 ms 332 KB Output is correct
35 Correct 1 ms 332 KB Output is correct
36 Correct 1 ms 588 KB Output is correct
37 Correct 2 ms 588 KB Output is correct
38 Correct 1 ms 460 KB Output is correct
39 Correct 1 ms 460 KB Output is correct
40 Correct 1 ms 460 KB Output is correct
41 Correct 1 ms 204 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 460 KB Output is correct
44 Correct 1 ms 460 KB Output is correct
45 Correct 2 ms 460 KB Output is correct
46 Correct 2 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 332 KB Output is correct
52 Correct 1 ms 332 KB Output is correct
53 Correct 2 ms 716 KB Output is correct
54 Correct 2 ms 716 KB Output is correct
55 Correct 2 ms 680 KB Output is correct
56 Correct 2 ms 716 KB Output is correct
57 Correct 2 ms 716 KB Output is correct
58 Correct 2 ms 716 KB Output is correct
59 Correct 2 ms 716 KB Output is correct
60 Correct 2 ms 716 KB Output is correct
61 Correct 2 ms 716 KB Output is correct
62 Correct 2 ms 716 KB Output is correct
63 Correct 2 ms 716 KB Output is correct
64 Correct 2 ms 716 KB Output is correct
65 Correct 2 ms 504 KB Output is correct
66 Correct 1 ms 332 KB Output is correct
67 Correct 3 ms 460 KB Output is correct
68 Correct 2 ms 460 KB Output is correct
69 Correct 3 ms 540 KB Output is correct
70 Correct 4 ms 716 KB Output is correct
71 Correct 4 ms 588 KB Output is correct
72 Correct 6 ms 472 KB Output is correct
73 Correct 2 ms 332 KB Output is correct
74 Correct 3 ms 460 KB Output is correct
75 Correct 3 ms 588 KB Output is correct
76 Correct 16 ms 1208 KB Output is correct
77 Correct 17 ms 1300 KB Output is correct
78 Correct 20 ms 1420 KB Output is correct
79 Correct 3 ms 716 KB Output is correct
80 Correct 3 ms 716 KB Output is correct
81 Correct 3 ms 716 KB Output is correct
82 Correct 3 ms 716 KB Output is correct
83 Correct 3 ms 716 KB Output is correct
84 Correct 5 ms 844 KB Output is correct
85 Correct 5 ms 844 KB Output is correct
86 Correct 5 ms 832 KB Output is correct
87 Correct 5 ms 844 KB Output is correct
88 Correct 5 ms 844 KB Output is correct
89 Correct 5 ms 844 KB Output is correct
90 Correct 23 ms 1824 KB Output is correct
91 Correct 24 ms 1880 KB Output is correct
92 Correct 23 ms 1924 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 352 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
16 Correct 3 ms 716 KB Output is correct
17 Correct 2 ms 716 KB Output is correct
18 Correct 2 ms 716 KB Output is correct
19 Correct 2 ms 648 KB Output is correct
20 Correct 2 ms 716 KB Output is correct
21 Correct 3 ms 716 KB Output is correct
22 Correct 3 ms 656 KB Output is correct
23 Correct 3 ms 716 KB Output is correct
24 Correct 16 ms 1504 KB Output is correct
25 Correct 16 ms 1456 KB Output is correct
26 Correct 16 ms 1380 KB Output is correct
27 Correct 11 ms 2380 KB Output is correct
28 Correct 10 ms 2380 KB Output is correct
29 Correct 10 ms 1996 KB Output is correct
30 Correct 5 ms 1612 KB Output is correct
31 Correct 5 ms 1484 KB Output is correct
32 Correct 5 ms 1484 KB Output is correct
33 Correct 690 ms 158968 KB Output is correct
34 Correct 693 ms 159056 KB Output is correct
35 Correct 691 ms 159088 KB Output is correct
36 Correct 725 ms 159088 KB Output is correct
37 Correct 700 ms 159092 KB Output is correct
38 Correct 713 ms 159124 KB Output is correct
39 Correct 1061 ms 159432 KB Output is correct
40 Correct 1076 ms 159432 KB Output is correct
41 Correct 1064 ms 159428 KB Output is correct
42 Correct 1 ms 204 KB Output is correct
43 Correct 1 ms 204 KB Output is correct
44 Correct 1 ms 204 KB Output is correct
45 Correct 1 ms 204 KB Output is correct
46 Correct 1 ms 332 KB Output is correct
47 Correct 1 ms 332 KB Output is correct
48 Correct 1 ms 332 KB Output is correct
49 Correct 1 ms 332 KB Output is correct
50 Correct 1 ms 332 KB Output is correct
51 Correct 1 ms 588 KB Output is correct
52 Correct 2 ms 588 KB Output is correct
53 Correct 1 ms 460 KB Output is correct
54 Correct 1 ms 460 KB Output is correct
55 Correct 1 ms 460 KB Output is correct
56 Correct 1 ms 204 KB Output is correct
57 Correct 1 ms 204 KB Output is correct
58 Correct 1 ms 460 KB Output is correct
59 Correct 1 ms 460 KB Output is correct
60 Correct 2 ms 460 KB Output is correct
61 Correct 2 ms 332 KB Output is correct
62 Correct 1 ms 332 KB Output is correct
63 Correct 1 ms 332 KB Output is correct
64 Correct 1 ms 332 KB Output is correct
65 Correct 1 ms 332 KB Output is correct
66 Correct 1 ms 332 KB Output is correct
67 Correct 1 ms 332 KB Output is correct
68 Correct 2 ms 716 KB Output is correct
69 Correct 2 ms 716 KB Output is correct
70 Correct 2 ms 680 KB Output is correct
71 Correct 2 ms 716 KB Output is correct
72 Correct 2 ms 716 KB Output is correct
73 Correct 2 ms 716 KB Output is correct
74 Correct 2 ms 716 KB Output is correct
75 Correct 2 ms 716 KB Output is correct
76 Correct 2 ms 716 KB Output is correct
77 Correct 2 ms 716 KB Output is correct
78 Correct 2 ms 716 KB Output is correct
79 Correct 2 ms 716 KB Output is correct
80 Correct 2 ms 504 KB Output is correct
81 Correct 1 ms 332 KB Output is correct
82 Correct 3 ms 460 KB Output is correct
83 Correct 2 ms 460 KB Output is correct
84 Correct 3 ms 540 KB Output is correct
85 Correct 4 ms 716 KB Output is correct
86 Correct 4 ms 588 KB Output is correct
87 Correct 6 ms 472 KB Output is correct
88 Correct 2 ms 332 KB Output is correct
89 Correct 3 ms 460 KB Output is correct
90 Correct 3 ms 588 KB Output is correct
91 Correct 16 ms 1208 KB Output is correct
92 Correct 17 ms 1300 KB Output is correct
93 Correct 20 ms 1420 KB Output is correct
94 Correct 3 ms 716 KB Output is correct
95 Correct 3 ms 716 KB Output is correct
96 Correct 3 ms 716 KB Output is correct
97 Correct 3 ms 716 KB Output is correct
98 Correct 3 ms 716 KB Output is correct
99 Correct 5 ms 844 KB Output is correct
100 Correct 5 ms 844 KB Output is correct
101 Correct 5 ms 832 KB Output is correct
102 Correct 5 ms 844 KB Output is correct
103 Correct 5 ms 844 KB Output is correct
104 Correct 5 ms 844 KB Output is correct
105 Correct 23 ms 1824 KB Output is correct
106 Correct 24 ms 1880 KB Output is correct
107 Correct 23 ms 1924 KB Output is correct
108 Correct 11 ms 2508 KB Output is correct
109 Correct 708 ms 36728 KB Output is correct
110 Correct 92 ms 31948 KB Output is correct
111 Correct 95 ms 31392 KB Output is correct
112 Correct 138 ms 44996 KB Output is correct
113 Correct 122 ms 40908 KB Output is correct
114 Correct 302 ms 45216 KB Output is correct
115 Correct 51 ms 4676 KB Output is correct
116 Correct 447 ms 54848 KB Output is correct
117 Correct 247 ms 31408 KB Output is correct
118 Correct 74 ms 6872 KB Output is correct
119 Correct 481 ms 86340 KB Output is correct
120 Correct 577 ms 93124 KB Output is correct
121 Correct 340 ms 92484 KB Output is correct
122 Correct 275 ms 27812 KB Output is correct
123 Correct 145 ms 26780 KB Output is correct
124 Correct 175 ms 14428 KB Output is correct
125 Correct 118 ms 13708 KB Output is correct
126 Correct 25 ms 2392 KB Output is correct
127 Correct 283 ms 40324 KB Output is correct
128 Correct 76 ms 8156 KB Output is correct
129 Correct 104 ms 11876 KB Output is correct
130 Correct 11 ms 2508 KB Output is correct
131 Correct 1103 ms 51920 KB Output is correct
132 Correct 186 ms 63948 KB Output is correct
133 Correct 210 ms 72096 KB Output is correct
134 Correct 247 ms 78788 KB Output is correct
135 Correct 272 ms 84576 KB Output is correct
136 Correct 972 ms 159892 KB Output is correct
137 Correct 981 ms 160196 KB Output is correct
138 Correct 977 ms 160068 KB Output is correct
139 Correct 970 ms 159944 KB Output is correct
140 Correct 986 ms 159940 KB Output is correct
141 Correct 973 ms 160068 KB Output is correct
142 Correct 1241 ms 160232 KB Output is correct
143 Correct 680 ms 159172 KB Output is correct
144 Correct 1236 ms 160196 KB Output is correct
145 Correct 714 ms 159068 KB Output is correct
146 Correct 1247 ms 160192 KB Output is correct
147 Correct 688 ms 159044 KB Output is correct
148 Correct 759 ms 158512 KB Output is correct
149 Correct 488 ms 80196 KB Output is correct
150 Correct 360 ms 53700 KB Output is correct
151 Correct 294 ms 40920 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 2 ms 352 KB Output is correct
11 Correct 1 ms 332 KB Output is correct
12 Correct 1 ms 204 KB Output is correct
13 Correct 1 ms 204 KB Output is correct
14 Correct 1 ms 204 KB Output is correct
15 Correct 2 ms 716 KB Output is correct
16 Correct 3 ms 716 KB Output is correct
17 Correct 2 ms 716 KB Output is correct
18 Correct 2 ms 716 KB Output is correct
19 Correct 2 ms 648 KB Output is correct
20 Correct 2 ms 716 KB Output is correct
21 Correct 3 ms 716 KB Output is correct
22 Correct 3 ms 656 KB Output is correct
23 Correct 3 ms 716 KB Output is correct
24 Correct 16 ms 1504 KB Output is correct
25 Correct 16 ms 1456 KB Output is correct
26 Correct 16 ms 1380 KB Output is correct
27 Correct 11 ms 2380 KB Output is correct
28 Correct 10 ms 2380 KB Output is correct
29 Correct 10 ms 1996 KB Output is correct
30 Correct 5 ms 1612 KB Output is correct
31 Correct 5 ms 1484 KB Output is correct
32 Correct 5 ms 1484 KB Output is correct
33 Correct 690 ms 158968 KB Output is correct
34 Correct 693 ms 159056 KB Output is correct
35 Correct 691 ms 159088 KB Output is correct
36 Correct 725 ms 159088 KB Output is correct
37 Correct 700 ms 159092 KB Output is correct
38 Correct 713 ms 159124 KB Output is correct
39 Correct 1061 ms 159432 KB Output is correct
40 Correct 1076 ms 159432 KB Output is correct
41 Correct 1064 ms 159428 KB Output is correct
42 Correct 47 ms 10320 KB Output is correct
43 Correct 31 ms 6600 KB Output is correct
44 Correct 31 ms 8932 KB Output is correct
45 Correct 17 ms 4784 KB Output is correct
46 Correct 13 ms 4140 KB Output is correct
47 Correct 22 ms 6644 KB Output is correct
48 Runtime error 271 ms 524292 KB Execution killed with signal 9
49 Halted 0 ms 0 KB -