# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
293376 | 2020-09-08T01:10:11 Z | daniel920712 | Painting Walls (APIO20_paint) | C++14 | 1500 ms | 336216 KB |
#include "paint.h" #include <vector> #include <stdio.h> #include <queue> using namespace std; bool can[2005][100005]={0}; int r[2005][20005]; int rr[20005]; int DP[20005]; vector < int > all; vector < int > how[200005]; int N,M; queue < pair < int , int > > now; int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A,vector< vector<int> > B) { int i,j,ok; all=C; ::N=N; ::M=M; for(i=0;i<M;i++) { for(j=0;j<A[i];j++) { can[i][B[i][j]]=1; how[B[i][j]].push_back(i); } } for(j=M-1;j>=0;j--) r[j][N]=N; for(i=N-1;i>=0;i--) { rr[i]=-1e9; for(j=M-1;j>=0;j--) { if(can[j][all[i]]==0) r[j][i]=-1e9; else r[j][i]=max(i,r[(j+1)%M][i+1]); rr[i]=max(rr[i],r[j][i]); } } now.push(make_pair(0,N)); for(i=N-1;i>=0;i--) { ok=0; DP[i]=1e9; while(!now.empty()&&now.front().second-i>M) now.pop(); if(i+M>N) continue; else { if(rr[i]>=i+M-1) { if(now.empty()) DP[i]=1e9; else { DP[i]=now.front().first+1; now.push(make_pair(DP[i],i)); } } } } int t=DP[0]; if(t>=1000000000) return -1; return t; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 4 ms | 4992 KB | Output is correct |
6 | Correct | 3 ms | 4992 KB | Output is correct |
7 | Correct | 3 ms | 4992 KB | Output is correct |
8 | Correct | 3 ms | 4992 KB | Output is correct |
9 | Correct | 4 ms | 4992 KB | Output is correct |
10 | Correct | 4 ms | 4992 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 4 ms | 5120 KB | Output is correct |
13 | Correct | 9 ms | 8320 KB | Output is correct |
14 | Correct | 9 ms | 8320 KB | Output is correct |
15 | Correct | 11 ms | 8192 KB | Output is correct |
16 | Correct | 9 ms | 8192 KB | Output is correct |
17 | Correct | 9 ms | 8192 KB | Output is correct |
18 | Correct | 10 ms | 8192 KB | Output is correct |
19 | Correct | 10 ms | 9856 KB | Output is correct |
20 | Correct | 10 ms | 9984 KB | Output is correct |
21 | Correct | 10 ms | 9984 KB | Output is correct |
22 | Correct | 46 ms | 29688 KB | Output is correct |
23 | Correct | 45 ms | 29688 KB | Output is correct |
24 | Correct | 48 ms | 29688 KB | Output is correct |
25 | Correct | 6 ms | 5504 KB | Output is correct |
26 | Correct | 6 ms | 5504 KB | Output is correct |
27 | Correct | 6 ms | 5504 KB | Output is correct |
28 | Correct | 6 ms | 5632 KB | Output is correct |
29 | Correct | 6 ms | 5760 KB | Output is correct |
30 | Correct | 7 ms | 5760 KB | Output is correct |
31 | Correct | 1427 ms | 230580 KB | Output is correct |
32 | Correct | 1435 ms | 230264 KB | Output is correct |
33 | Correct | 1421 ms | 230048 KB | Output is correct |
34 | Correct | 1440 ms | 230220 KB | Output is correct |
35 | Correct | 1411 ms | 230312 KB | Output is correct |
36 | Correct | 1437 ms | 230288 KB | Output is correct |
37 | Execution timed out | 1584 ms | 336216 KB | Time limit exceeded |
38 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 3 ms | 4992 KB | Output is correct |
7 | Correct | 4 ms | 4992 KB | Output is correct |
8 | Correct | 3 ms | 4992 KB | Output is correct |
9 | Correct | 3 ms | 4992 KB | Output is correct |
10 | Correct | 3 ms | 4992 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 4 ms | 4992 KB | Output is correct |
13 | Correct | 4 ms | 4992 KB | Output is correct |
14 | Correct | 4 ms | 5120 KB | Output is correct |
15 | Correct | 9 ms | 8320 KB | Output is correct |
16 | Correct | 9 ms | 8320 KB | Output is correct |
17 | Correct | 11 ms | 8192 KB | Output is correct |
18 | Correct | 9 ms | 8192 KB | Output is correct |
19 | Correct | 9 ms | 8192 KB | Output is correct |
20 | Correct | 10 ms | 8192 KB | Output is correct |
21 | Correct | 10 ms | 9856 KB | Output is correct |
22 | Correct | 10 ms | 9984 KB | Output is correct |
23 | Correct | 10 ms | 9984 KB | Output is correct |
24 | Correct | 3 ms | 4992 KB | Output is correct |
25 | Correct | 3 ms | 4992 KB | Output is correct |
26 | Correct | 3 ms | 4992 KB | Output is correct |
27 | Correct | 4 ms | 4992 KB | Output is correct |
28 | Correct | 4 ms | 5248 KB | Output is correct |
29 | Correct | 4 ms | 5376 KB | Output is correct |
30 | Correct | 4 ms | 5248 KB | Output is correct |
31 | Correct | 3 ms | 5120 KB | Output is correct |
32 | Correct | 4 ms | 5504 KB | Output is correct |
33 | Correct | 7 ms | 7552 KB | Output is correct |
34 | Correct | 7 ms | 7680 KB | Output is correct |
35 | Correct | 6 ms | 6912 KB | Output is correct |
36 | Correct | 7 ms | 7424 KB | Output is correct |
37 | Correct | 7 ms | 7296 KB | Output is correct |
38 | Correct | 4 ms | 5376 KB | Output is correct |
39 | Correct | 4 ms | 5120 KB | Output is correct |
40 | Correct | 8 ms | 9216 KB | Output is correct |
41 | Correct | 5 ms | 6656 KB | Output is correct |
42 | Correct | 7 ms | 7936 KB | Output is correct |
43 | Correct | 5 ms | 6784 KB | Output is correct |
44 | Correct | 5 ms | 4992 KB | Output is correct |
45 | Correct | 4 ms | 5376 KB | Output is correct |
46 | Correct | 4 ms | 5504 KB | Output is correct |
47 | Correct | 4 ms | 5504 KB | Output is correct |
48 | Correct | 4 ms | 5632 KB | Output is correct |
49 | Correct | 4 ms | 5632 KB | Output is correct |
50 | Correct | 9 ms | 8192 KB | Output is correct |
51 | Correct | 9 ms | 8320 KB | Output is correct |
52 | Correct | 11 ms | 8192 KB | Output is correct |
53 | Correct | 9 ms | 8192 KB | Output is correct |
54 | Correct | 9 ms | 8320 KB | Output is correct |
55 | Correct | 9 ms | 8192 KB | Output is correct |
56 | Correct | 10 ms | 9984 KB | Output is correct |
57 | Correct | 5 ms | 7168 KB | Output is correct |
58 | Correct | 10 ms | 9856 KB | Output is correct |
59 | Correct | 6 ms | 7168 KB | Output is correct |
60 | Correct | 10 ms | 9856 KB | Output is correct |
61 | Correct | 5 ms | 7168 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 3 ms | 4992 KB | Output is correct |
7 | Correct | 4 ms | 4992 KB | Output is correct |
8 | Correct | 3 ms | 4992 KB | Output is correct |
9 | Correct | 3 ms | 4992 KB | Output is correct |
10 | Correct | 3 ms | 4992 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 4 ms | 4992 KB | Output is correct |
13 | Correct | 4 ms | 4992 KB | Output is correct |
14 | Correct | 4 ms | 5120 KB | Output is correct |
15 | Correct | 9 ms | 8320 KB | Output is correct |
16 | Correct | 9 ms | 8320 KB | Output is correct |
17 | Correct | 11 ms | 8192 KB | Output is correct |
18 | Correct | 9 ms | 8192 KB | Output is correct |
19 | Correct | 9 ms | 8192 KB | Output is correct |
20 | Correct | 10 ms | 8192 KB | Output is correct |
21 | Correct | 10 ms | 9856 KB | Output is correct |
22 | Correct | 10 ms | 9984 KB | Output is correct |
23 | Correct | 10 ms | 9984 KB | Output is correct |
24 | Correct | 46 ms | 29688 KB | Output is correct |
25 | Correct | 45 ms | 29688 KB | Output is correct |
26 | Correct | 48 ms | 29688 KB | Output is correct |
27 | Correct | 3 ms | 4992 KB | Output is correct |
28 | Correct | 3 ms | 4992 KB | Output is correct |
29 | Correct | 3 ms | 4992 KB | Output is correct |
30 | Correct | 4 ms | 4992 KB | Output is correct |
31 | Correct | 4 ms | 5248 KB | Output is correct |
32 | Correct | 4 ms | 5376 KB | Output is correct |
33 | Correct | 4 ms | 5248 KB | Output is correct |
34 | Correct | 3 ms | 5120 KB | Output is correct |
35 | Correct | 4 ms | 5504 KB | Output is correct |
36 | Correct | 7 ms | 7552 KB | Output is correct |
37 | Correct | 7 ms | 7680 KB | Output is correct |
38 | Correct | 6 ms | 6912 KB | Output is correct |
39 | Correct | 7 ms | 7424 KB | Output is correct |
40 | Correct | 7 ms | 7296 KB | Output is correct |
41 | Correct | 4 ms | 5376 KB | Output is correct |
42 | Correct | 4 ms | 5120 KB | Output is correct |
43 | Correct | 8 ms | 9216 KB | Output is correct |
44 | Correct | 5 ms | 6656 KB | Output is correct |
45 | Correct | 7 ms | 7936 KB | Output is correct |
46 | Correct | 5 ms | 6784 KB | Output is correct |
47 | Correct | 5 ms | 4992 KB | Output is correct |
48 | Correct | 4 ms | 5376 KB | Output is correct |
49 | Correct | 4 ms | 5504 KB | Output is correct |
50 | Correct | 4 ms | 5504 KB | Output is correct |
51 | Correct | 4 ms | 5632 KB | Output is correct |
52 | Correct | 4 ms | 5632 KB | Output is correct |
53 | Correct | 9 ms | 8192 KB | Output is correct |
54 | Correct | 9 ms | 8320 KB | Output is correct |
55 | Correct | 11 ms | 8192 KB | Output is correct |
56 | Correct | 9 ms | 8192 KB | Output is correct |
57 | Correct | 9 ms | 8320 KB | Output is correct |
58 | Correct | 9 ms | 8192 KB | Output is correct |
59 | Correct | 10 ms | 9984 KB | Output is correct |
60 | Correct | 5 ms | 7168 KB | Output is correct |
61 | Correct | 10 ms | 9856 KB | Output is correct |
62 | Correct | 6 ms | 7168 KB | Output is correct |
63 | Correct | 10 ms | 9856 KB | Output is correct |
64 | Correct | 5 ms | 7168 KB | Output is correct |
65 | Correct | 5 ms | 6784 KB | Output is correct |
66 | Correct | 4 ms | 5376 KB | Output is correct |
67 | Correct | 6 ms | 6272 KB | Output is correct |
68 | Correct | 4 ms | 5760 KB | Output is correct |
69 | Correct | 6 ms | 6272 KB | Output is correct |
70 | Correct | 16 ms | 20992 KB | Output is correct |
71 | Correct | 13 ms | 16768 KB | Output is correct |
72 | Correct | 9 ms | 10496 KB | Output is correct |
73 | Correct | 5 ms | 6400 KB | Output is correct |
74 | Correct | 11 ms | 14336 KB | Output is correct |
75 | Correct | 15 ms | 21504 KB | Output is correct |
76 | Correct | 39 ms | 16504 KB | Output is correct |
77 | Correct | 30 ms | 8440 KB | Output is correct |
78 | Correct | 44 ms | 11904 KB | Output is correct |
79 | Correct | 5 ms | 7040 KB | Output is correct |
80 | Correct | 5 ms | 7040 KB | Output is correct |
81 | Correct | 5 ms | 7040 KB | Output is correct |
82 | Correct | 5 ms | 7040 KB | Output is correct |
83 | Correct | 5 ms | 7040 KB | Output is correct |
84 | Correct | 19 ms | 24952 KB | Output is correct |
85 | Correct | 19 ms | 25088 KB | Output is correct |
86 | Correct | 19 ms | 25088 KB | Output is correct |
87 | Correct | 19 ms | 25088 KB | Output is correct |
88 | Correct | 19 ms | 25088 KB | Output is correct |
89 | Correct | 18 ms | 24832 KB | Output is correct |
90 | Correct | 71 ms | 29560 KB | Output is correct |
91 | Correct | 70 ms | 29692 KB | Output is correct |
92 | Correct | 64 ms | 29688 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 3 ms | 4992 KB | Output is correct |
7 | Correct | 4 ms | 4992 KB | Output is correct |
8 | Correct | 3 ms | 4992 KB | Output is correct |
9 | Correct | 3 ms | 4992 KB | Output is correct |
10 | Correct | 3 ms | 4992 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 4 ms | 4992 KB | Output is correct |
13 | Correct | 4 ms | 4992 KB | Output is correct |
14 | Correct | 4 ms | 5120 KB | Output is correct |
15 | Correct | 9 ms | 8320 KB | Output is correct |
16 | Correct | 9 ms | 8320 KB | Output is correct |
17 | Correct | 11 ms | 8192 KB | Output is correct |
18 | Correct | 9 ms | 8192 KB | Output is correct |
19 | Correct | 9 ms | 8192 KB | Output is correct |
20 | Correct | 10 ms | 8192 KB | Output is correct |
21 | Correct | 10 ms | 9856 KB | Output is correct |
22 | Correct | 10 ms | 9984 KB | Output is correct |
23 | Correct | 10 ms | 9984 KB | Output is correct |
24 | Correct | 46 ms | 29688 KB | Output is correct |
25 | Correct | 45 ms | 29688 KB | Output is correct |
26 | Correct | 48 ms | 29688 KB | Output is correct |
27 | Correct | 6 ms | 5504 KB | Output is correct |
28 | Correct | 6 ms | 5504 KB | Output is correct |
29 | Correct | 6 ms | 5504 KB | Output is correct |
30 | Correct | 6 ms | 5632 KB | Output is correct |
31 | Correct | 6 ms | 5760 KB | Output is correct |
32 | Correct | 7 ms | 5760 KB | Output is correct |
33 | Correct | 1427 ms | 230580 KB | Output is correct |
34 | Correct | 1435 ms | 230264 KB | Output is correct |
35 | Correct | 1421 ms | 230048 KB | Output is correct |
36 | Correct | 1440 ms | 230220 KB | Output is correct |
37 | Correct | 1411 ms | 230312 KB | Output is correct |
38 | Correct | 1437 ms | 230288 KB | Output is correct |
39 | Execution timed out | 1584 ms | 336216 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 3 ms | 4992 KB | Output is correct |
2 | Correct | 3 ms | 4992 KB | Output is correct |
3 | Correct | 3 ms | 4992 KB | Output is correct |
4 | Correct | 3 ms | 4992 KB | Output is correct |
5 | Correct | 3 ms | 4992 KB | Output is correct |
6 | Correct | 3 ms | 4992 KB | Output is correct |
7 | Correct | 4 ms | 4992 KB | Output is correct |
8 | Correct | 3 ms | 4992 KB | Output is correct |
9 | Correct | 3 ms | 4992 KB | Output is correct |
10 | Correct | 3 ms | 4992 KB | Output is correct |
11 | Correct | 4 ms | 4992 KB | Output is correct |
12 | Correct | 4 ms | 4992 KB | Output is correct |
13 | Correct | 4 ms | 4992 KB | Output is correct |
14 | Correct | 4 ms | 5120 KB | Output is correct |
15 | Correct | 9 ms | 8320 KB | Output is correct |
16 | Correct | 9 ms | 8320 KB | Output is correct |
17 | Correct | 11 ms | 8192 KB | Output is correct |
18 | Correct | 9 ms | 8192 KB | Output is correct |
19 | Correct | 9 ms | 8192 KB | Output is correct |
20 | Correct | 10 ms | 8192 KB | Output is correct |
21 | Correct | 10 ms | 9856 KB | Output is correct |
22 | Correct | 10 ms | 9984 KB | Output is correct |
23 | Correct | 10 ms | 9984 KB | Output is correct |
24 | Correct | 46 ms | 29688 KB | Output is correct |
25 | Correct | 45 ms | 29688 KB | Output is correct |
26 | Correct | 48 ms | 29688 KB | Output is correct |
27 | Correct | 6 ms | 5504 KB | Output is correct |
28 | Correct | 6 ms | 5504 KB | Output is correct |
29 | Correct | 6 ms | 5504 KB | Output is correct |
30 | Correct | 6 ms | 5632 KB | Output is correct |
31 | Correct | 6 ms | 5760 KB | Output is correct |
32 | Correct | 7 ms | 5760 KB | Output is correct |
33 | Correct | 1427 ms | 230580 KB | Output is correct |
34 | Correct | 1435 ms | 230264 KB | Output is correct |
35 | Correct | 1421 ms | 230048 KB | Output is correct |
36 | Correct | 1440 ms | 230220 KB | Output is correct |
37 | Correct | 1411 ms | 230312 KB | Output is correct |
38 | Correct | 1437 ms | 230288 KB | Output is correct |
39 | Execution timed out | 1584 ms | 336216 KB | Time limit exceeded |
40 | Halted | 0 ms | 0 KB | - |