답안 #935179

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
935179 2024-02-28T18:58:59 Z MinaRagy06 벽 칠하기 (APIO20_paint) C++17
28 / 100
1500 ms 59144 KB
#include <bits/stdc++.h>
#ifdef MINA
#include "grader.cpp"
#endif
#include "paint.h"
using namespace std;
#define ll long long

int minimumInstructions(int n, int m, int K, vector<int> a, vector<int> sz, vector<vector<int>> b) {
	vector<int> col[K];
	for (int i = 0; i < m; i++) {
		for (auto j : b[i]) {
			col[j].push_back(i);
		}
	}
	vector<int> diff[n];
	for (int i = 0; i < n; i++) {
		for (auto j : col[a[i]]) {
			diff[i].push_back(i - j);
		}
		sort(diff[i].begin(), diff[i].end());
	}
	int dp[n + 1]{};
	dp[n] = 0;
	for (int i = n - 1; i > n - m; i--) {
		dp[i] = 1e9;
	}
	for (int i = n - m; i >= 0; i--) {
		dp[i] = 1e9;
		bool ok = 0;
		for (auto j : col[a[i]]) {
			bool gud = 1;
			int st = i + m - j;
			for (int k = i; k < st; k++) {
				gud &= binary_search(diff[k].begin(), diff[k].end(), i - j);
			}
			for (int k = st; k < i + m; k++) {
				gud &= binary_search(diff[k].begin(), diff[k].end(), st);
			}
			ok |= gud;
		}
		if (ok) {
			for (int j = i + 1; j <= i + m; j++) {
				dp[i] = min(dp[i], dp[j] + 1);
			}
		}
	}
	if (dp[0] >= (int)1e9) return -1;
	return dp[0];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 2 ms 2856 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 2 ms 2648 KB Output is correct
22 Correct 15 ms 7252 KB Output is correct
23 Correct 19 ms 7504 KB Output is correct
24 Correct 17 ms 7272 KB Output is correct
25 Correct 3 ms 1700 KB Output is correct
26 Correct 3 ms 1624 KB Output is correct
27 Correct 4 ms 1628 KB Output is correct
28 Correct 3 ms 1624 KB Output is correct
29 Correct 3 ms 1628 KB Output is correct
30 Correct 4 ms 1624 KB Output is correct
31 Correct 135 ms 5240 KB Output is correct
32 Correct 131 ms 5212 KB Output is correct
33 Correct 137 ms 5212 KB Output is correct
34 Correct 131 ms 5244 KB Output is correct
35 Correct 134 ms 5212 KB Output is correct
36 Correct 135 ms 5240 KB Output is correct
37 Correct 214 ms 8796 KB Output is correct
38 Correct 211 ms 8856 KB Output is correct
39 Correct 209 ms 8860 KB Output is correct
40 Correct 17 ms 6492 KB Output is correct
41 Correct 8 ms 4192 KB Output is correct
42 Correct 15 ms 7004 KB Output is correct
43 Correct 10 ms 4920 KB Output is correct
44 Correct 9 ms 4444 KB Output is correct
45 Correct 16 ms 7512 KB Output is correct
46 Execution timed out 1555 ms 17748 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 344 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 348 KB Output is correct
13 Correct 2 ms 2652 KB Output is correct
14 Correct 2 ms 2652 KB Output is correct
15 Correct 2 ms 2856 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 2 ms 2652 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 2 ms 2648 KB Output is correct
22 Correct 1 ms 344 KB Output is correct
23 Correct 0 ms 344 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 1 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 348 KB Output is correct
30 Correct 2 ms 664 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 2396 KB Output is correct
34 Correct 2 ms 1880 KB Output is correct
35 Correct 1 ms 1628 KB Output is correct
36 Correct 2 ms 2652 KB Output is correct
37 Correct 2 ms 2140 KB Output is correct
38 Correct 2 ms 2396 KB Output is correct
39 Correct 1 ms 344 KB Output is correct
40 Correct 2 ms 2140 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2392 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 4 ms 524 KB Output is correct
46 Correct 5 ms 348 KB Output is correct
47 Correct 5 ms 436 KB Output is correct
48 Correct 7 ms 348 KB Output is correct
49 Correct 5 ms 440 KB Output is correct
50 Correct 2 ms 2904 KB Output is correct
51 Correct 2 ms 2652 KB Output is correct
52 Correct 2 ms 3160 KB Output is correct
53 Correct 3 ms 2652 KB Output is correct
54 Correct 3 ms 2652 KB Output is correct
55 Correct 2 ms 2652 KB Output is correct
56 Correct 2 ms 2748 KB Output is correct
57 Correct 1 ms 516 KB Output is correct
58 Correct 2 ms 2652 KB Output is correct
59 Correct 2 ms 512 KB Output is correct
60 Correct 2 ms 2652 KB Output is correct
61 Correct 1 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 2 ms 2856 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
23 Correct 2 ms 2648 KB Output is correct
24 Correct 15 ms 7252 KB Output is correct
25 Correct 19 ms 7504 KB Output is correct
26 Correct 17 ms 7272 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 2 ms 348 KB Output is correct
32 Correct 2 ms 348 KB Output is correct
33 Correct 2 ms 664 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 2 ms 348 KB Output is correct
36 Correct 2 ms 2396 KB Output is correct
37 Correct 2 ms 1880 KB Output is correct
38 Correct 1 ms 1628 KB Output is correct
39 Correct 2 ms 2652 KB Output is correct
40 Correct 2 ms 2140 KB Output is correct
41 Correct 2 ms 2396 KB Output is correct
42 Correct 1 ms 344 KB Output is correct
43 Correct 2 ms 2140 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 2 ms 2652 KB Output is correct
46 Correct 2 ms 2392 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 4 ms 524 KB Output is correct
49 Correct 5 ms 348 KB Output is correct
50 Correct 5 ms 436 KB Output is correct
51 Correct 7 ms 348 KB Output is correct
52 Correct 5 ms 440 KB Output is correct
53 Correct 2 ms 2904 KB Output is correct
54 Correct 2 ms 2652 KB Output is correct
55 Correct 2 ms 3160 KB Output is correct
56 Correct 3 ms 2652 KB Output is correct
57 Correct 3 ms 2652 KB Output is correct
58 Correct 2 ms 2652 KB Output is correct
59 Correct 2 ms 2748 KB Output is correct
60 Correct 1 ms 516 KB Output is correct
61 Correct 2 ms 2652 KB Output is correct
62 Correct 2 ms 512 KB Output is correct
63 Correct 2 ms 2652 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 28 ms 724 KB Output is correct
66 Correct 8 ms 600 KB Output is correct
67 Correct 62 ms 604 KB Output is correct
68 Correct 22 ms 604 KB Output is correct
69 Correct 51 ms 680 KB Output is correct
70 Correct 11 ms 2652 KB Output is correct
71 Correct 12 ms 2140 KB Output is correct
72 Correct 9 ms 1884 KB Output is correct
73 Correct 3 ms 2264 KB Output is correct
74 Correct 13 ms 2560 KB Output is correct
75 Correct 8 ms 2908 KB Output is correct
76 Correct 15 ms 5208 KB Output is correct
77 Correct 25 ms 6080 KB Output is correct
78 Correct 19 ms 7000 KB Output is correct
79 Correct 149 ms 956 KB Output is correct
80 Correct 143 ms 960 KB Output is correct
81 Correct 144 ms 860 KB Output is correct
82 Correct 174 ms 968 KB Output is correct
83 Correct 143 ms 968 KB Output is correct
84 Correct 17 ms 3160 KB Output is correct
85 Correct 17 ms 3160 KB Output is correct
86 Correct 18 ms 3184 KB Output is correct
87 Correct 17 ms 3160 KB Output is correct
88 Correct 17 ms 3164 KB Output is correct
89 Correct 18 ms 3164 KB Output is correct
90 Correct 24 ms 7252 KB Output is correct
91 Correct 21 ms 7260 KB Output is correct
92 Correct 21 ms 7372 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 2 ms 2856 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
23 Correct 2 ms 2648 KB Output is correct
24 Correct 15 ms 7252 KB Output is correct
25 Correct 19 ms 7504 KB Output is correct
26 Correct 17 ms 7272 KB Output is correct
27 Correct 3 ms 1700 KB Output is correct
28 Correct 3 ms 1624 KB Output is correct
29 Correct 4 ms 1628 KB Output is correct
30 Correct 3 ms 1624 KB Output is correct
31 Correct 3 ms 1628 KB Output is correct
32 Correct 4 ms 1624 KB Output is correct
33 Correct 135 ms 5240 KB Output is correct
34 Correct 131 ms 5212 KB Output is correct
35 Correct 137 ms 5212 KB Output is correct
36 Correct 131 ms 5244 KB Output is correct
37 Correct 134 ms 5212 KB Output is correct
38 Correct 135 ms 5240 KB Output is correct
39 Correct 214 ms 8796 KB Output is correct
40 Correct 211 ms 8856 KB Output is correct
41 Correct 209 ms 8860 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 2 ms 348 KB Output is correct
47 Correct 2 ms 348 KB Output is correct
48 Correct 2 ms 664 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 2 ms 348 KB Output is correct
51 Correct 2 ms 2396 KB Output is correct
52 Correct 2 ms 1880 KB Output is correct
53 Correct 1 ms 1628 KB Output is correct
54 Correct 2 ms 2652 KB Output is correct
55 Correct 2 ms 2140 KB Output is correct
56 Correct 2 ms 2396 KB Output is correct
57 Correct 1 ms 344 KB Output is correct
58 Correct 2 ms 2140 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 2 ms 2652 KB Output is correct
61 Correct 2 ms 2392 KB Output is correct
62 Correct 1 ms 348 KB Output is correct
63 Correct 4 ms 524 KB Output is correct
64 Correct 5 ms 348 KB Output is correct
65 Correct 5 ms 436 KB Output is correct
66 Correct 7 ms 348 KB Output is correct
67 Correct 5 ms 440 KB Output is correct
68 Correct 2 ms 2904 KB Output is correct
69 Correct 2 ms 2652 KB Output is correct
70 Correct 2 ms 3160 KB Output is correct
71 Correct 3 ms 2652 KB Output is correct
72 Correct 3 ms 2652 KB Output is correct
73 Correct 2 ms 2652 KB Output is correct
74 Correct 2 ms 2748 KB Output is correct
75 Correct 1 ms 516 KB Output is correct
76 Correct 2 ms 2652 KB Output is correct
77 Correct 2 ms 512 KB Output is correct
78 Correct 2 ms 2652 KB Output is correct
79 Correct 1 ms 348 KB Output is correct
80 Correct 28 ms 724 KB Output is correct
81 Correct 8 ms 600 KB Output is correct
82 Correct 62 ms 604 KB Output is correct
83 Correct 22 ms 604 KB Output is correct
84 Correct 51 ms 680 KB Output is correct
85 Correct 11 ms 2652 KB Output is correct
86 Correct 12 ms 2140 KB Output is correct
87 Correct 9 ms 1884 KB Output is correct
88 Correct 3 ms 2264 KB Output is correct
89 Correct 13 ms 2560 KB Output is correct
90 Correct 8 ms 2908 KB Output is correct
91 Correct 15 ms 5208 KB Output is correct
92 Correct 25 ms 6080 KB Output is correct
93 Correct 19 ms 7000 KB Output is correct
94 Correct 149 ms 956 KB Output is correct
95 Correct 143 ms 960 KB Output is correct
96 Correct 144 ms 860 KB Output is correct
97 Correct 174 ms 968 KB Output is correct
98 Correct 143 ms 968 KB Output is correct
99 Correct 17 ms 3160 KB Output is correct
100 Correct 17 ms 3160 KB Output is correct
101 Correct 18 ms 3184 KB Output is correct
102 Correct 17 ms 3160 KB Output is correct
103 Correct 17 ms 3164 KB Output is correct
104 Correct 18 ms 3164 KB Output is correct
105 Correct 24 ms 7252 KB Output is correct
106 Correct 21 ms 7260 KB Output is correct
107 Correct 21 ms 7372 KB Output is correct
108 Correct 4 ms 1628 KB Output is correct
109 Execution timed out 1601 ms 59144 KB Time limit exceeded
110 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 344 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 2 ms 2652 KB Output is correct
16 Correct 2 ms 2652 KB Output is correct
17 Correct 2 ms 2856 KB Output is correct
18 Correct 2 ms 2652 KB Output is correct
19 Correct 2 ms 2652 KB Output is correct
20 Correct 2 ms 2652 KB Output is correct
21 Correct 2 ms 2652 KB Output is correct
22 Correct 2 ms 2652 KB Output is correct
23 Correct 2 ms 2648 KB Output is correct
24 Correct 15 ms 7252 KB Output is correct
25 Correct 19 ms 7504 KB Output is correct
26 Correct 17 ms 7272 KB Output is correct
27 Correct 3 ms 1700 KB Output is correct
28 Correct 3 ms 1624 KB Output is correct
29 Correct 4 ms 1628 KB Output is correct
30 Correct 3 ms 1624 KB Output is correct
31 Correct 3 ms 1628 KB Output is correct
32 Correct 4 ms 1624 KB Output is correct
33 Correct 135 ms 5240 KB Output is correct
34 Correct 131 ms 5212 KB Output is correct
35 Correct 137 ms 5212 KB Output is correct
36 Correct 131 ms 5244 KB Output is correct
37 Correct 134 ms 5212 KB Output is correct
38 Correct 135 ms 5240 KB Output is correct
39 Correct 214 ms 8796 KB Output is correct
40 Correct 211 ms 8856 KB Output is correct
41 Correct 209 ms 8860 KB Output is correct
42 Correct 17 ms 6492 KB Output is correct
43 Correct 8 ms 4192 KB Output is correct
44 Correct 15 ms 7004 KB Output is correct
45 Correct 10 ms 4920 KB Output is correct
46 Correct 9 ms 4444 KB Output is correct
47 Correct 16 ms 7512 KB Output is correct
48 Execution timed out 1555 ms 17748 KB Time limit exceeded
49 Halted 0 ms 0 KB -