Submission #996493

# Submission time Handle Problem Language Result Execution time Memory
996493 2024-06-10T17:20:54 Z Dan4Life Painting Walls (APIO20_paint) C++17
51 / 100
1117 ms 90004 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
 
#define all(a) begin(a),end(a)
#define sz(a) (int)a.size()
#define pb push_back
 
const int mxN = (int)2e4+10; 
const int mxM = (int)2e3+10; 
int n, m, k;
bool work[mxN];
vector<int> c, a;
set<int> b[mxN];

bool has[mxM][mxN], has2[mxM][mxN];

//has[x][y] = if contractor x contains the color used in cell y

bool check(int i){
	for(int x = 0; x < m; x++){
		if(!x){
			if(has2[x][i]) return true;
		}
		else if(has2[x][i] and has[x-1][i+m-1]) return true;
	}
	return false;
}
 
int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) {
	n = N, m = M, k = K;
	for(auto u : C) c.pb(u);
	for(auto u : A) a.pb(u);
	for(int i = 0; i < m; i++)
		for(auto u : B[i]) b[i].insert(u);
		
	memset(has,0,sizeof(has));
	
	for(int i = 0; i < m; i++)
		for(int j = 0; j < n; j++)
			has[i][j] = has2[i][j] = b[i].count(c[j]);
			
	for(int i = 1; i < m; i++)
		for(int j = 1; j < n; j++)
			has[i][j] &= has[i-1][j-1];
	for(int i = m-2; i>=0; i--)
		for(int j = n-2; j>=0; j--)
			has2[i][j] &= has2[i+1][j+1];
			
	memset(work,0,sizeof(work));
	for(int i = 0; i <= n-m; i++) work[i] = check(i);
	if(!work[0] or !work[n-m]) return -1;
	
	int tot = 1;
	for(int i = 0; i < n-m;){
		int j;
		for(j = i+m; j>=i; j--)
			if(work[j]) break;
		if(j==i) return -1;
		tot++; i = j;
	}
	return tot;
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 40796 KB Output is correct
2 Correct 5 ms 40796 KB Output is correct
3 Correct 6 ms 40832 KB Output is correct
4 Correct 6 ms 40796 KB Output is correct
5 Correct 6 ms 40796 KB Output is correct
6 Correct 5 ms 40796 KB Output is correct
7 Correct 6 ms 40944 KB Output is correct
8 Correct 5 ms 40796 KB Output is correct
9 Correct 6 ms 40792 KB Output is correct
10 Correct 6 ms 40796 KB Output is correct
11 Correct 6 ms 40796 KB Output is correct
12 Correct 7 ms 40796 KB Output is correct
13 Correct 7 ms 44892 KB Output is correct
14 Correct 7 ms 44892 KB Output is correct
15 Correct 7 ms 44892 KB Output is correct
16 Correct 9 ms 44892 KB Output is correct
17 Correct 7 ms 44984 KB Output is correct
18 Correct 7 ms 44892 KB Output is correct
19 Correct 8 ms 45024 KB Output is correct
20 Correct 7 ms 45144 KB Output is correct
21 Correct 7 ms 45148 KB Output is correct
22 Correct 23 ms 50416 KB Output is correct
23 Correct 23 ms 50516 KB Output is correct
24 Correct 24 ms 50512 KB Output is correct
25 Correct 7 ms 41304 KB Output is correct
26 Correct 9 ms 41308 KB Output is correct
27 Correct 8 ms 41308 KB Output is correct
28 Correct 7 ms 41304 KB Output is correct
29 Correct 9 ms 41304 KB Output is correct
30 Correct 9 ms 41184 KB Output is correct
31 Correct 554 ms 81532 KB Output is correct
32 Correct 558 ms 81488 KB Output is correct
33 Correct 570 ms 81488 KB Output is correct
34 Correct 573 ms 81556 KB Output is correct
35 Correct 564 ms 81788 KB Output is correct
36 Correct 549 ms 81484 KB Output is correct
37 Correct 991 ms 85844 KB Output is correct
38 Correct 992 ms 85892 KB Output is correct
39 Correct 956 ms 85964 KB Output is correct
40 Runtime error 39 ms 85196 KB Execution killed with signal 11
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 40796 KB Output is correct
2 Correct 5 ms 40796 KB Output is correct
3 Correct 6 ms 40832 KB Output is correct
4 Correct 6 ms 40796 KB Output is correct
5 Correct 6 ms 40796 KB Output is correct
6 Correct 5 ms 40796 KB Output is correct
7 Correct 6 ms 40944 KB Output is correct
8 Correct 5 ms 40796 KB Output is correct
9 Correct 6 ms 40792 KB Output is correct
10 Correct 6 ms 40796 KB Output is correct
11 Correct 6 ms 40796 KB Output is correct
12 Correct 7 ms 40796 KB Output is correct
13 Correct 7 ms 44892 KB Output is correct
14 Correct 7 ms 44892 KB Output is correct
15 Correct 7 ms 44892 KB Output is correct
16 Correct 9 ms 44892 KB Output is correct
17 Correct 7 ms 44984 KB Output is correct
18 Correct 7 ms 44892 KB Output is correct
19 Correct 8 ms 45024 KB Output is correct
20 Correct 7 ms 45144 KB Output is correct
21 Correct 7 ms 45148 KB Output is correct
22 Correct 5 ms 40792 KB Output is correct
23 Correct 5 ms 40792 KB Output is correct
24 Correct 5 ms 40884 KB Output is correct
25 Correct 5 ms 40724 KB Output is correct
26 Correct 5 ms 40792 KB Output is correct
27 Correct 6 ms 40796 KB Output is correct
28 Correct 5 ms 42888 KB Output is correct
29 Correct 6 ms 42852 KB Output is correct
30 Correct 6 ms 42844 KB Output is correct
31 Correct 5 ms 40796 KB Output is correct
32 Correct 6 ms 42844 KB Output is correct
33 Correct 7 ms 44892 KB Output is correct
34 Correct 7 ms 44892 KB Output is correct
35 Correct 6 ms 44892 KB Output is correct
36 Correct 6 ms 44888 KB Output is correct
37 Correct 6 ms 44892 KB Output is correct
38 Correct 6 ms 40796 KB Output is correct
39 Correct 5 ms 40796 KB Output is correct
40 Correct 6 ms 45148 KB Output is correct
41 Correct 6 ms 44892 KB Output is correct
42 Correct 6 ms 43068 KB Output is correct
43 Correct 6 ms 42840 KB Output is correct
44 Correct 5 ms 40860 KB Output is correct
45 Correct 7 ms 42864 KB Output is correct
46 Correct 6 ms 42844 KB Output is correct
47 Correct 5 ms 42844 KB Output is correct
48 Correct 6 ms 42924 KB Output is correct
49 Correct 5 ms 42844 KB Output is correct
50 Correct 6 ms 44892 KB Output is correct
51 Correct 6 ms 44892 KB Output is correct
52 Correct 7 ms 44892 KB Output is correct
53 Correct 7 ms 44888 KB Output is correct
54 Correct 6 ms 44888 KB Output is correct
55 Correct 7 ms 44888 KB Output is correct
56 Correct 7 ms 45148 KB Output is correct
57 Correct 7 ms 44892 KB Output is correct
58 Correct 6 ms 45148 KB Output is correct
59 Correct 6 ms 44892 KB Output is correct
60 Correct 7 ms 45148 KB Output is correct
61 Correct 8 ms 44892 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 40792 KB Output is correct
2 Correct 5 ms 40792 KB Output is correct
3 Correct 5 ms 40796 KB Output is correct
4 Correct 5 ms 40796 KB Output is correct
5 Correct 6 ms 40832 KB Output is correct
6 Correct 6 ms 40796 KB Output is correct
7 Correct 6 ms 40796 KB Output is correct
8 Correct 5 ms 40796 KB Output is correct
9 Correct 6 ms 40944 KB Output is correct
10 Correct 5 ms 40796 KB Output is correct
11 Correct 6 ms 40792 KB Output is correct
12 Correct 6 ms 40796 KB Output is correct
13 Correct 6 ms 40796 KB Output is correct
14 Correct 7 ms 40796 KB Output is correct
15 Correct 7 ms 44892 KB Output is correct
16 Correct 7 ms 44892 KB Output is correct
17 Correct 7 ms 44892 KB Output is correct
18 Correct 9 ms 44892 KB Output is correct
19 Correct 7 ms 44984 KB Output is correct
20 Correct 7 ms 44892 KB Output is correct
21 Correct 8 ms 45024 KB Output is correct
22 Correct 7 ms 45144 KB Output is correct
23 Correct 7 ms 45148 KB Output is correct
24 Correct 23 ms 50416 KB Output is correct
25 Correct 23 ms 50516 KB Output is correct
26 Correct 24 ms 50512 KB Output is correct
27 Correct 5 ms 40884 KB Output is correct
28 Correct 5 ms 40724 KB Output is correct
29 Correct 5 ms 40792 KB Output is correct
30 Correct 6 ms 40796 KB Output is correct
31 Correct 5 ms 42888 KB Output is correct
32 Correct 6 ms 42852 KB Output is correct
33 Correct 6 ms 42844 KB Output is correct
34 Correct 5 ms 40796 KB Output is correct
35 Correct 6 ms 42844 KB Output is correct
36 Correct 7 ms 44892 KB Output is correct
37 Correct 7 ms 44892 KB Output is correct
38 Correct 6 ms 44892 KB Output is correct
39 Correct 6 ms 44888 KB Output is correct
40 Correct 6 ms 44892 KB Output is correct
41 Correct 6 ms 40796 KB Output is correct
42 Correct 5 ms 40796 KB Output is correct
43 Correct 6 ms 45148 KB Output is correct
44 Correct 6 ms 44892 KB Output is correct
45 Correct 6 ms 43068 KB Output is correct
46 Correct 6 ms 42840 KB Output is correct
47 Correct 5 ms 40860 KB Output is correct
48 Correct 7 ms 42864 KB Output is correct
49 Correct 6 ms 42844 KB Output is correct
50 Correct 5 ms 42844 KB Output is correct
51 Correct 6 ms 42924 KB Output is correct
52 Correct 5 ms 42844 KB Output is correct
53 Correct 6 ms 44892 KB Output is correct
54 Correct 6 ms 44892 KB Output is correct
55 Correct 7 ms 44892 KB Output is correct
56 Correct 7 ms 44888 KB Output is correct
57 Correct 6 ms 44888 KB Output is correct
58 Correct 7 ms 44888 KB Output is correct
59 Correct 7 ms 45148 KB Output is correct
60 Correct 7 ms 44892 KB Output is correct
61 Correct 6 ms 45148 KB Output is correct
62 Correct 6 ms 44892 KB Output is correct
63 Correct 7 ms 45148 KB Output is correct
64 Correct 8 ms 44892 KB Output is correct
65 Correct 6 ms 44892 KB Output is correct
66 Correct 5 ms 42844 KB Output is correct
67 Correct 6 ms 44892 KB Output is correct
68 Correct 5 ms 42840 KB Output is correct
69 Correct 6 ms 44892 KB Output is correct
70 Correct 9 ms 45520 KB Output is correct
71 Correct 9 ms 45660 KB Output is correct
72 Correct 8 ms 43612 KB Output is correct
73 Correct 7 ms 43268 KB Output is correct
74 Correct 7 ms 43612 KB Output is correct
75 Correct 9 ms 45392 KB Output is correct
76 Correct 22 ms 48988 KB Output is correct
77 Correct 28 ms 47708 KB Output is correct
78 Correct 32 ms 50780 KB Output is correct
79 Correct 6 ms 44888 KB Output is correct
80 Correct 6 ms 44888 KB Output is correct
81 Correct 6 ms 45148 KB Output is correct
82 Correct 6 ms 44992 KB Output is correct
83 Correct 6 ms 45144 KB Output is correct
84 Correct 10 ms 45660 KB Output is correct
85 Correct 11 ms 45660 KB Output is correct
86 Correct 11 ms 45660 KB Output is correct
87 Correct 10 ms 45700 KB Output is correct
88 Correct 10 ms 45724 KB Output is correct
89 Correct 12 ms 45736 KB Output is correct
90 Correct 31 ms 53644 KB Output is correct
91 Correct 31 ms 53596 KB Output is correct
92 Correct 33 ms 53596 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 40792 KB Output is correct
2 Correct 5 ms 40792 KB Output is correct
3 Correct 5 ms 40796 KB Output is correct
4 Correct 5 ms 40796 KB Output is correct
5 Correct 6 ms 40832 KB Output is correct
6 Correct 6 ms 40796 KB Output is correct
7 Correct 6 ms 40796 KB Output is correct
8 Correct 5 ms 40796 KB Output is correct
9 Correct 6 ms 40944 KB Output is correct
10 Correct 5 ms 40796 KB Output is correct
11 Correct 6 ms 40792 KB Output is correct
12 Correct 6 ms 40796 KB Output is correct
13 Correct 6 ms 40796 KB Output is correct
14 Correct 7 ms 40796 KB Output is correct
15 Correct 7 ms 44892 KB Output is correct
16 Correct 7 ms 44892 KB Output is correct
17 Correct 7 ms 44892 KB Output is correct
18 Correct 9 ms 44892 KB Output is correct
19 Correct 7 ms 44984 KB Output is correct
20 Correct 7 ms 44892 KB Output is correct
21 Correct 8 ms 45024 KB Output is correct
22 Correct 7 ms 45144 KB Output is correct
23 Correct 7 ms 45148 KB Output is correct
24 Correct 23 ms 50416 KB Output is correct
25 Correct 23 ms 50516 KB Output is correct
26 Correct 24 ms 50512 KB Output is correct
27 Correct 7 ms 41304 KB Output is correct
28 Correct 9 ms 41308 KB Output is correct
29 Correct 8 ms 41308 KB Output is correct
30 Correct 7 ms 41304 KB Output is correct
31 Correct 9 ms 41304 KB Output is correct
32 Correct 9 ms 41184 KB Output is correct
33 Correct 554 ms 81532 KB Output is correct
34 Correct 558 ms 81488 KB Output is correct
35 Correct 570 ms 81488 KB Output is correct
36 Correct 573 ms 81556 KB Output is correct
37 Correct 564 ms 81788 KB Output is correct
38 Correct 549 ms 81484 KB Output is correct
39 Correct 991 ms 85844 KB Output is correct
40 Correct 992 ms 85892 KB Output is correct
41 Correct 956 ms 85964 KB Output is correct
42 Correct 5 ms 40884 KB Output is correct
43 Correct 5 ms 40724 KB Output is correct
44 Correct 5 ms 40792 KB Output is correct
45 Correct 6 ms 40796 KB Output is correct
46 Correct 5 ms 42888 KB Output is correct
47 Correct 6 ms 42852 KB Output is correct
48 Correct 6 ms 42844 KB Output is correct
49 Correct 5 ms 40796 KB Output is correct
50 Correct 6 ms 42844 KB Output is correct
51 Correct 7 ms 44892 KB Output is correct
52 Correct 7 ms 44892 KB Output is correct
53 Correct 6 ms 44892 KB Output is correct
54 Correct 6 ms 44888 KB Output is correct
55 Correct 6 ms 44892 KB Output is correct
56 Correct 6 ms 40796 KB Output is correct
57 Correct 5 ms 40796 KB Output is correct
58 Correct 6 ms 45148 KB Output is correct
59 Correct 6 ms 44892 KB Output is correct
60 Correct 6 ms 43068 KB Output is correct
61 Correct 6 ms 42840 KB Output is correct
62 Correct 5 ms 40860 KB Output is correct
63 Correct 7 ms 42864 KB Output is correct
64 Correct 6 ms 42844 KB Output is correct
65 Correct 5 ms 42844 KB Output is correct
66 Correct 6 ms 42924 KB Output is correct
67 Correct 5 ms 42844 KB Output is correct
68 Correct 6 ms 44892 KB Output is correct
69 Correct 6 ms 44892 KB Output is correct
70 Correct 7 ms 44892 KB Output is correct
71 Correct 7 ms 44888 KB Output is correct
72 Correct 6 ms 44888 KB Output is correct
73 Correct 7 ms 44888 KB Output is correct
74 Correct 7 ms 45148 KB Output is correct
75 Correct 7 ms 44892 KB Output is correct
76 Correct 6 ms 45148 KB Output is correct
77 Correct 6 ms 44892 KB Output is correct
78 Correct 7 ms 45148 KB Output is correct
79 Correct 8 ms 44892 KB Output is correct
80 Correct 6 ms 44892 KB Output is correct
81 Correct 5 ms 42844 KB Output is correct
82 Correct 6 ms 44892 KB Output is correct
83 Correct 5 ms 42840 KB Output is correct
84 Correct 6 ms 44892 KB Output is correct
85 Correct 9 ms 45520 KB Output is correct
86 Correct 9 ms 45660 KB Output is correct
87 Correct 8 ms 43612 KB Output is correct
88 Correct 7 ms 43268 KB Output is correct
89 Correct 7 ms 43612 KB Output is correct
90 Correct 9 ms 45392 KB Output is correct
91 Correct 22 ms 48988 KB Output is correct
92 Correct 28 ms 47708 KB Output is correct
93 Correct 32 ms 50780 KB Output is correct
94 Correct 6 ms 44888 KB Output is correct
95 Correct 6 ms 44888 KB Output is correct
96 Correct 6 ms 45148 KB Output is correct
97 Correct 6 ms 44992 KB Output is correct
98 Correct 6 ms 45144 KB Output is correct
99 Correct 10 ms 45660 KB Output is correct
100 Correct 11 ms 45660 KB Output is correct
101 Correct 11 ms 45660 KB Output is correct
102 Correct 10 ms 45700 KB Output is correct
103 Correct 10 ms 45724 KB Output is correct
104 Correct 12 ms 45736 KB Output is correct
105 Correct 31 ms 53644 KB Output is correct
106 Correct 31 ms 53596 KB Output is correct
107 Correct 33 ms 53596 KB Output is correct
108 Correct 7 ms 41304 KB Output is correct
109 Correct 31 ms 53592 KB Output is correct
110 Correct 48 ms 55636 KB Output is correct
111 Correct 56 ms 55892 KB Output is correct
112 Correct 73 ms 55636 KB Output is correct
113 Correct 64 ms 59828 KB Output is correct
114 Correct 269 ms 65184 KB Output is correct
115 Correct 47 ms 46940 KB Output is correct
116 Correct 370 ms 60224 KB Output is correct
117 Correct 205 ms 58964 KB Output is correct
118 Correct 64 ms 46936 KB Output is correct
119 Correct 419 ms 74784 KB Output is correct
120 Correct 538 ms 85840 KB Output is correct
121 Correct 271 ms 80980 KB Output is correct
122 Correct 229 ms 60648 KB Output is correct
123 Correct 124 ms 54100 KB Output is correct
124 Correct 153 ms 53144 KB Output is correct
125 Correct 96 ms 46420 KB Output is correct
126 Correct 24 ms 44632 KB Output is correct
127 Correct 253 ms 55496 KB Output is correct
128 Correct 63 ms 46420 KB Output is correct
129 Correct 84 ms 46672 KB Output is correct
130 Correct 6 ms 41304 KB Output is correct
131 Correct 41 ms 53844 KB Output is correct
132 Correct 99 ms 57992 KB Output is correct
133 Correct 113 ms 59988 KB Output is correct
134 Correct 121 ms 62108 KB Output is correct
135 Correct 136 ms 64168 KB Output is correct
136 Correct 853 ms 85400 KB Output is correct
137 Correct 850 ms 85332 KB Output is correct
138 Correct 865 ms 85328 KB Output is correct
139 Correct 875 ms 85428 KB Output is correct
140 Correct 854 ms 85424 KB Output is correct
141 Correct 864 ms 85400 KB Output is correct
142 Correct 1091 ms 90004 KB Output is correct
143 Correct 548 ms 81720 KB Output is correct
144 Correct 1117 ms 89996 KB Output is correct
145 Correct 541 ms 81704 KB Output is correct
146 Correct 1055 ms 89896 KB Output is correct
147 Correct 545 ms 81744 KB Output is correct
148 Correct 651 ms 82260 KB Output is correct
149 Correct 408 ms 63824 KB Output is correct
150 Correct 304 ms 57680 KB Output is correct
151 Correct 249 ms 53328 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 40792 KB Output is correct
2 Correct 5 ms 40792 KB Output is correct
3 Correct 5 ms 40796 KB Output is correct
4 Correct 5 ms 40796 KB Output is correct
5 Correct 6 ms 40832 KB Output is correct
6 Correct 6 ms 40796 KB Output is correct
7 Correct 6 ms 40796 KB Output is correct
8 Correct 5 ms 40796 KB Output is correct
9 Correct 6 ms 40944 KB Output is correct
10 Correct 5 ms 40796 KB Output is correct
11 Correct 6 ms 40792 KB Output is correct
12 Correct 6 ms 40796 KB Output is correct
13 Correct 6 ms 40796 KB Output is correct
14 Correct 7 ms 40796 KB Output is correct
15 Correct 7 ms 44892 KB Output is correct
16 Correct 7 ms 44892 KB Output is correct
17 Correct 7 ms 44892 KB Output is correct
18 Correct 9 ms 44892 KB Output is correct
19 Correct 7 ms 44984 KB Output is correct
20 Correct 7 ms 44892 KB Output is correct
21 Correct 8 ms 45024 KB Output is correct
22 Correct 7 ms 45144 KB Output is correct
23 Correct 7 ms 45148 KB Output is correct
24 Correct 23 ms 50416 KB Output is correct
25 Correct 23 ms 50516 KB Output is correct
26 Correct 24 ms 50512 KB Output is correct
27 Correct 7 ms 41304 KB Output is correct
28 Correct 9 ms 41308 KB Output is correct
29 Correct 8 ms 41308 KB Output is correct
30 Correct 7 ms 41304 KB Output is correct
31 Correct 9 ms 41304 KB Output is correct
32 Correct 9 ms 41184 KB Output is correct
33 Correct 554 ms 81532 KB Output is correct
34 Correct 558 ms 81488 KB Output is correct
35 Correct 570 ms 81488 KB Output is correct
36 Correct 573 ms 81556 KB Output is correct
37 Correct 564 ms 81788 KB Output is correct
38 Correct 549 ms 81484 KB Output is correct
39 Correct 991 ms 85844 KB Output is correct
40 Correct 992 ms 85892 KB Output is correct
41 Correct 956 ms 85964 KB Output is correct
42 Runtime error 39 ms 85196 KB Execution killed with signal 11
43 Halted 0 ms 0 KB -