# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
576636 | 2022-06-13T08:47:40 Z | pnm1384 | 벽 칠하기 (APIO20_paint) | C++14 | 58 ms | 17960 KB |
#include "paint.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second const int N = 3e5 + 20; vector<int> vt[N]; int col[N], last[N], dp[N]; bool have[N]; vector<int> vt1, vt2; int minimumInstructions(int N, int M, int K, std::vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) { int n = N, m = M, k = K; for (int i = 0; i < n; i++) { col[i] = C[i]; } for (int i = 0; i < m; i++) { for (int j = 0; j < A[i]; j++) { int c = B[i][j]; vt[c].push_back(i); } } for (int i = 0; i < m; i++) { last[i] = -2; dp[i] = -2; } for (int i = 0; i < n; i++) { vt1.clear(); vt2.clear(); for (int j : vt[col[i]]) { int j2 = j - 1; if (j2 < 0) j2 = m - 1; if (last[j2] == i - 1) { vt1.push_back(j); } else { vt2.push_back(j); } } for (int j : vt1) { int j2 = j - 1; if (j2 < 0) j2 = m - 1; dp[j] = min(dp[j2] + 1, m); assert(dp[j] <= i + 1); last[j] = i; } for (int j : vt2) { dp[j] = 1; last[j] = i; } for (int j : vt[col[i]]) { if (dp[j] == m) { have[i - m + 1] = true; //assert(i - m + 1 >= 0); } } } int i = 0, j = 0; int ans = 0; while (i < n) { int ff = -1; for (int kk = i; kk >= j; kk--) { if (have[kk]) { ff = kk; break; } } if (ff == -1) return -1; ans++; j = i + 1; i = m + ff; } return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 7252 KB | Output is correct |
2 | Correct | 4 ms | 7252 KB | Output is correct |
3 | Correct | 3 ms | 7252 KB | Output is correct |
4 | Correct | 4 ms | 7252 KB | Output is correct |
5 | Correct | 5 ms | 7252 KB | Output is correct |
6 | Correct | 3 ms | 7256 KB | Output is correct |
7 | Correct | 5 ms | 7380 KB | Output is correct |
8 | Correct | 5 ms | 7252 KB | Output is correct |
9 | Correct | 4 ms | 7252 KB | Output is correct |
10 | Correct | 4 ms | 7252 KB | Output is correct |
11 | Correct | 4 ms | 7380 KB | Output is correct |
12 | Correct | 4 ms | 7380 KB | Output is correct |
13 | Correct | 4 ms | 7380 KB | Output is correct |
14 | Correct | 4 ms | 7360 KB | Output is correct |
15 | Correct | 4 ms | 7380 KB | Output is correct |
16 | Correct | 4 ms | 7380 KB | Output is correct |
17 | Correct | 4 ms | 7412 KB | Output is correct |
18 | Correct | 4 ms | 7380 KB | Output is correct |
19 | Correct | 4 ms | 7380 KB | Output is correct |
20 | Correct | 5 ms | 7380 KB | Output is correct |
21 | Correct | 4 ms | 7380 KB | Output is correct |
22 | Correct | 22 ms | 11192 KB | Output is correct |
23 | Correct | 27 ms | 11312 KB | Output is correct |
24 | Correct | 26 ms | 11232 KB | Output is correct |
25 | Correct | 6 ms | 7680 KB | Output is correct |
26 | Correct | 6 ms | 7508 KB | Output is correct |
27 | Correct | 6 ms | 7508 KB | Output is correct |
28 | Correct | 6 ms | 7628 KB | Output is correct |
29 | Correct | 5 ms | 7508 KB | Output is correct |
30 | Correct | 6 ms | 7508 KB | Output is correct |
31 | Correct | 10 ms | 8532 KB | Output is correct |
32 | Correct | 10 ms | 8528 KB | Output is correct |
33 | Correct | 11 ms | 8556 KB | Output is correct |
34 | Correct | 11 ms | 8532 KB | Output is correct |
35 | Correct | 12 ms | 8504 KB | Output is correct |
36 | Correct | 13 ms | 8532 KB | Output is correct |
37 | Correct | 23 ms | 11704 KB | Output is correct |
38 | Correct | 24 ms | 11672 KB | Output is correct |
39 | Correct | 29 ms | 11608 KB | Output is correct |
40 | Correct | 13 ms | 8532 KB | Output is correct |
41 | Correct | 9 ms | 8020 KB | Output is correct |
42 | Correct | 13 ms | 8516 KB | Output is correct |
43 | Correct | 9 ms | 8128 KB | Output is correct |
44 | Correct | 9 ms | 8020 KB | Output is correct |
45 | Correct | 14 ms | 8532 KB | Output is correct |
46 | Correct | 41 ms | 17128 KB | Output is correct |
47 | Correct | 33 ms | 12812 KB | Output is correct |
48 | Correct | 30 ms | 15400 KB | Output is correct |
49 | Correct | 40 ms | 15576 KB | Output is correct |
50 | Correct | 44 ms | 15288 KB | Output is correct |
51 | Correct | 32 ms | 12904 KB | Output is correct |
52 | Correct | 14 ms | 8532 KB | Output is correct |
53 | Correct | 13 ms | 8532 KB | Output is correct |
54 | Correct | 14 ms | 8656 KB | Output is correct |
55 | Correct | 13 ms | 8532 KB | Output is correct |
56 | Correct | 17 ms | 8652 KB | Output is correct |
57 | Correct | 12 ms | 8532 KB | Output is correct |
58 | Correct | 46 ms | 17868 KB | Output is correct |
59 | Correct | 48 ms | 17936 KB | Output is correct |
60 | Correct | 47 ms | 17856 KB | Output is correct |
61 | Correct | 48 ms | 17960 KB | Output is correct |
62 | Correct | 48 ms | 17932 KB | Output is correct |
63 | Correct | 46 ms | 17876 KB | Output is correct |
64 | Correct | 48 ms | 17044 KB | Output is correct |
65 | Correct | 58 ms | 17000 KB | Output is correct |
66 | Correct | 50 ms | 17044 KB | Output is correct |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 7252 KB | Output is correct |
2 | Correct | 4 ms | 7252 KB | Output is correct |
3 | Correct | 3 ms | 7252 KB | Output is correct |
4 | Correct | 4 ms | 7252 KB | Output is correct |
5 | Correct | 5 ms | 7252 KB | Output is correct |
6 | Correct | 3 ms | 7256 KB | Output is correct |
7 | Correct | 5 ms | 7380 KB | Output is correct |
8 | Correct | 5 ms | 7252 KB | Output is correct |
9 | Correct | 4 ms | 7252 KB | Output is correct |
10 | Correct | 4 ms | 7252 KB | Output is correct |
11 | Correct | 4 ms | 7380 KB | Output is correct |
12 | Correct | 4 ms | 7380 KB | Output is correct |
13 | Correct | 4 ms | 7380 KB | Output is correct |
14 | Correct | 4 ms | 7360 KB | Output is correct |
15 | Correct | 4 ms | 7380 KB | Output is correct |
16 | Correct | 4 ms | 7380 KB | Output is correct |
17 | Correct | 4 ms | 7412 KB | Output is correct |
18 | Correct | 4 ms | 7380 KB | Output is correct |
19 | Correct | 4 ms | 7380 KB | Output is correct |
20 | Correct | 5 ms | 7380 KB | Output is correct |
21 | Correct | 4 ms | 7380 KB | Output is correct |
22 | Correct | 4 ms | 7252 KB | Output is correct |
23 | Correct | 4 ms | 7252 KB | Output is correct |
24 | Correct | 4 ms | 7252 KB | Output is correct |
25 | Correct | 5 ms | 7252 KB | Output is correct |
26 | Correct | 4 ms | 7264 KB | Output is correct |
27 | Correct | 4 ms | 7252 KB | Output is correct |
28 | Runtime error | 11 ms | 14784 KB | Execution killed with signal 6 |
29 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 7252 KB | Output is correct |
2 | Correct | 4 ms | 7252 KB | Output is correct |
3 | Correct | 4 ms | 7252 KB | Output is correct |
4 | Correct | 4 ms | 7252 KB | Output is correct |
5 | Correct | 3 ms | 7252 KB | Output is correct |
6 | Correct | 4 ms | 7252 KB | Output is correct |
7 | Correct | 5 ms | 7252 KB | Output is correct |
8 | Correct | 3 ms | 7256 KB | Output is correct |
9 | Correct | 5 ms | 7380 KB | Output is correct |
10 | Correct | 5 ms | 7252 KB | Output is correct |
11 | Correct | 4 ms | 7252 KB | Output is correct |
12 | Correct | 4 ms | 7252 KB | Output is correct |
13 | Correct | 4 ms | 7380 KB | Output is correct |
14 | Correct | 4 ms | 7380 KB | Output is correct |
15 | Correct | 4 ms | 7380 KB | Output is correct |
16 | Correct | 4 ms | 7360 KB | Output is correct |
17 | Correct | 4 ms | 7380 KB | Output is correct |
18 | Correct | 4 ms | 7380 KB | Output is correct |
19 | Correct | 4 ms | 7412 KB | Output is correct |
20 | Correct | 4 ms | 7380 KB | Output is correct |
21 | Correct | 4 ms | 7380 KB | Output is correct |
22 | Correct | 5 ms | 7380 KB | Output is correct |
23 | Correct | 4 ms | 7380 KB | Output is correct |
24 | Correct | 22 ms | 11192 KB | Output is correct |
25 | Correct | 27 ms | 11312 KB | Output is correct |
26 | Correct | 26 ms | 11232 KB | Output is correct |
27 | Correct | 4 ms | 7252 KB | Output is correct |
28 | Correct | 5 ms | 7252 KB | Output is correct |
29 | Correct | 4 ms | 7264 KB | Output is correct |
30 | Correct | 4 ms | 7252 KB | Output is correct |
31 | Runtime error | 11 ms | 14784 KB | Execution killed with signal 6 |
32 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 7252 KB | Output is correct |
2 | Correct | 4 ms | 7252 KB | Output is correct |
3 | Correct | 4 ms | 7252 KB | Output is correct |
4 | Correct | 4 ms | 7252 KB | Output is correct |
5 | Correct | 3 ms | 7252 KB | Output is correct |
6 | Correct | 4 ms | 7252 KB | Output is correct |
7 | Correct | 5 ms | 7252 KB | Output is correct |
8 | Correct | 3 ms | 7256 KB | Output is correct |
9 | Correct | 5 ms | 7380 KB | Output is correct |
10 | Correct | 5 ms | 7252 KB | Output is correct |
11 | Correct | 4 ms | 7252 KB | Output is correct |
12 | Correct | 4 ms | 7252 KB | Output is correct |
13 | Correct | 4 ms | 7380 KB | Output is correct |
14 | Correct | 4 ms | 7380 KB | Output is correct |
15 | Correct | 4 ms | 7380 KB | Output is correct |
16 | Correct | 4 ms | 7360 KB | Output is correct |
17 | Correct | 4 ms | 7380 KB | Output is correct |
18 | Correct | 4 ms | 7380 KB | Output is correct |
19 | Correct | 4 ms | 7412 KB | Output is correct |
20 | Correct | 4 ms | 7380 KB | Output is correct |
21 | Correct | 4 ms | 7380 KB | Output is correct |
22 | Correct | 5 ms | 7380 KB | Output is correct |
23 | Correct | 4 ms | 7380 KB | Output is correct |
24 | Correct | 22 ms | 11192 KB | Output is correct |
25 | Correct | 27 ms | 11312 KB | Output is correct |
26 | Correct | 26 ms | 11232 KB | Output is correct |
27 | Correct | 6 ms | 7680 KB | Output is correct |
28 | Correct | 6 ms | 7508 KB | Output is correct |
29 | Correct | 6 ms | 7508 KB | Output is correct |
30 | Correct | 6 ms | 7628 KB | Output is correct |
31 | Correct | 5 ms | 7508 KB | Output is correct |
32 | Correct | 6 ms | 7508 KB | Output is correct |
33 | Correct | 10 ms | 8532 KB | Output is correct |
34 | Correct | 10 ms | 8528 KB | Output is correct |
35 | Correct | 11 ms | 8556 KB | Output is correct |
36 | Correct | 11 ms | 8532 KB | Output is correct |
37 | Correct | 12 ms | 8504 KB | Output is correct |
38 | Correct | 13 ms | 8532 KB | Output is correct |
39 | Correct | 23 ms | 11704 KB | Output is correct |
40 | Correct | 24 ms | 11672 KB | Output is correct |
41 | Correct | 29 ms | 11608 KB | Output is correct |
42 | Correct | 4 ms | 7252 KB | Output is correct |
43 | Correct | 5 ms | 7252 KB | Output is correct |
44 | Correct | 4 ms | 7264 KB | Output is correct |
45 | Correct | 4 ms | 7252 KB | Output is correct |
46 | Runtime error | 11 ms | 14784 KB | Execution killed with signal 6 |
47 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 4 ms | 7252 KB | Output is correct |
2 | Correct | 4 ms | 7252 KB | Output is correct |
3 | Correct | 4 ms | 7252 KB | Output is correct |
4 | Correct | 4 ms | 7252 KB | Output is correct |
5 | Correct | 3 ms | 7252 KB | Output is correct |
6 | Correct | 4 ms | 7252 KB | Output is correct |
7 | Correct | 5 ms | 7252 KB | Output is correct |
8 | Correct | 3 ms | 7256 KB | Output is correct |
9 | Correct | 5 ms | 7380 KB | Output is correct |
10 | Correct | 5 ms | 7252 KB | Output is correct |
11 | Correct | 4 ms | 7252 KB | Output is correct |
12 | Correct | 4 ms | 7252 KB | Output is correct |
13 | Correct | 4 ms | 7380 KB | Output is correct |
14 | Correct | 4 ms | 7380 KB | Output is correct |
15 | Correct | 4 ms | 7380 KB | Output is correct |
16 | Correct | 4 ms | 7360 KB | Output is correct |
17 | Correct | 4 ms | 7380 KB | Output is correct |
18 | Correct | 4 ms | 7380 KB | Output is correct |
19 | Correct | 4 ms | 7412 KB | Output is correct |
20 | Correct | 4 ms | 7380 KB | Output is correct |
21 | Correct | 4 ms | 7380 KB | Output is correct |
22 | Correct | 5 ms | 7380 KB | Output is correct |
23 | Correct | 4 ms | 7380 KB | Output is correct |
24 | Correct | 22 ms | 11192 KB | Output is correct |
25 | Correct | 27 ms | 11312 KB | Output is correct |
26 | Correct | 26 ms | 11232 KB | Output is correct |
27 | Correct | 6 ms | 7680 KB | Output is correct |
28 | Correct | 6 ms | 7508 KB | Output is correct |
29 | Correct | 6 ms | 7508 KB | Output is correct |
30 | Correct | 6 ms | 7628 KB | Output is correct |
31 | Correct | 5 ms | 7508 KB | Output is correct |
32 | Correct | 6 ms | 7508 KB | Output is correct |
33 | Correct | 10 ms | 8532 KB | Output is correct |
34 | Correct | 10 ms | 8528 KB | Output is correct |
35 | Correct | 11 ms | 8556 KB | Output is correct |
36 | Correct | 11 ms | 8532 KB | Output is correct |
37 | Correct | 12 ms | 8504 KB | Output is correct |
38 | Correct | 13 ms | 8532 KB | Output is correct |
39 | Correct | 23 ms | 11704 KB | Output is correct |
40 | Correct | 24 ms | 11672 KB | Output is correct |
41 | Correct | 29 ms | 11608 KB | Output is correct |
42 | Correct | 13 ms | 8532 KB | Output is correct |
43 | Correct | 9 ms | 8020 KB | Output is correct |
44 | Correct | 13 ms | 8516 KB | Output is correct |
45 | Correct | 9 ms | 8128 KB | Output is correct |
46 | Correct | 9 ms | 8020 KB | Output is correct |
47 | Correct | 14 ms | 8532 KB | Output is correct |
48 | Correct | 41 ms | 17128 KB | Output is correct |
49 | Correct | 33 ms | 12812 KB | Output is correct |
50 | Correct | 30 ms | 15400 KB | Output is correct |
51 | Correct | 40 ms | 15576 KB | Output is correct |
52 | Correct | 44 ms | 15288 KB | Output is correct |
53 | Correct | 32 ms | 12904 KB | Output is correct |
54 | Correct | 14 ms | 8532 KB | Output is correct |
55 | Correct | 13 ms | 8532 KB | Output is correct |
56 | Correct | 14 ms | 8656 KB | Output is correct |
57 | Correct | 13 ms | 8532 KB | Output is correct |
58 | Correct | 17 ms | 8652 KB | Output is correct |
59 | Correct | 12 ms | 8532 KB | Output is correct |
60 | Correct | 46 ms | 17868 KB | Output is correct |
61 | Correct | 48 ms | 17936 KB | Output is correct |
62 | Correct | 47 ms | 17856 KB | Output is correct |
63 | Correct | 48 ms | 17960 KB | Output is correct |
64 | Correct | 48 ms | 17932 KB | Output is correct |
65 | Correct | 46 ms | 17876 KB | Output is correct |
66 | Correct | 48 ms | 17044 KB | Output is correct |
67 | Correct | 58 ms | 17000 KB | Output is correct |
68 | Correct | 50 ms | 17044 KB | Output is correct |
69 | Correct | 4 ms | 7252 KB | Output is correct |
70 | Correct | 5 ms | 7252 KB | Output is correct |
71 | Correct | 4 ms | 7264 KB | Output is correct |
72 | Correct | 4 ms | 7252 KB | Output is correct |
73 | Runtime error | 11 ms | 14784 KB | Execution killed with signal 6 |
74 | Halted | 0 ms | 0 KB | - |