Submission #965749

# Submission time Handle Problem Language Result Execution time Memory
965749 2024-04-19T06:52:07 Z Darren0724 Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 24660 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
const int INF=1e9;
int minimumInstructions(int N, int M, int K, vector<int> C,vector<int> A, vector<vector<int>> B) {
  	vector<int> dp(N+1,INF);
	vector<unordered_set<int>> s(K);
	for(int i=0;i<M;i++){
		for(int j:B[i]){
			s[j].insert(i);
		}
	}
	auto check=[&](int st,int now)->int {
		for(int i=st;i<st+M;i++){
			if(!s[C[i]].count(now))return 0;
			now++;
			now%=M;
		}
		return 1;
	};	
	deque<int> d;
	d.push_back(0);
	dp[0]=0;
	for(int i=M;i<=N;i++){
		while(d.size()&&d.front()<i-M){
			d.pop_front();
		}
		int flag=0;
		for(int j=0;j<M;j++){
			flag|=check(i-M,j);
		}
		if(flag){
			dp[i]=dp[d.front()]+1;
		}
		while(d.size()&&dp[d.back()]>dp[i]){
			d.pop_back();
		}
		d.push_back(i);
	}
	return (dp[N]>=INF?-1:dp[N]);

	return 0;
}
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 4 ms 5980 KB Output is correct
14 Correct 3 ms 5980 KB Output is correct
15 Correct 3 ms 5980 KB Output is correct
16 Correct 3 ms 5976 KB Output is correct
17 Correct 3 ms 5980 KB Output is correct
18 Correct 3 ms 5980 KB Output is correct
19 Correct 3 ms 5980 KB Output is correct
20 Correct 3 ms 5980 KB Output is correct
21 Correct 3 ms 5988 KB Output is correct
22 Correct 41 ms 20588 KB Output is correct
23 Correct 35 ms 20572 KB Output is correct
24 Correct 34 ms 20572 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 600 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 587 ms 9068 KB Output is correct
32 Correct 606 ms 9216 KB Output is correct
33 Correct 600 ms 9052 KB Output is correct
34 Correct 590 ms 9284 KB Output is correct
35 Correct 602 ms 9048 KB Output is correct
36 Correct 595 ms 9252 KB Output is correct
37 Correct 269 ms 21084 KB Output is correct
38 Correct 267 ms 21080 KB Output is correct
39 Correct 267 ms 21084 KB Output is correct
40 Correct 7 ms 1372 KB Output is correct
41 Correct 5 ms 1112 KB Output is correct
42 Correct 10 ms 1600 KB Output is correct
43 Correct 7 ms 1116 KB Output is correct
44 Correct 7 ms 1116 KB Output is correct
45 Correct 11 ms 1372 KB Output is correct
46 Execution timed out 1565 ms 24660 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 1 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 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 4 ms 5980 KB Output is correct
14 Correct 3 ms 5980 KB Output is correct
15 Correct 3 ms 5980 KB Output is correct
16 Correct 3 ms 5976 KB Output is correct
17 Correct 3 ms 5980 KB Output is correct
18 Correct 3 ms 5980 KB Output is correct
19 Correct 3 ms 5980 KB Output is correct
20 Correct 3 ms 5980 KB Output is correct
21 Correct 3 ms 5988 KB Output is correct
22 Correct 0 ms 600 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 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 3 ms 344 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 0 ms 600 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 3 ms 5212 KB Output is correct
34 Correct 3 ms 3932 KB Output is correct
35 Correct 2 ms 3420 KB Output is correct
36 Correct 4 ms 5724 KB Output is correct
37 Correct 3 ms 4700 KB Output is correct
38 Correct 3 ms 5212 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 2 ms 4700 KB Output is correct
41 Correct 1 ms 348 KB Output is correct
42 Correct 3 ms 5724 KB Output is correct
43 Correct 2 ms 5464 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 6 ms 348 KB Output is correct
46 Correct 1 ms 348 KB Output is correct
47 Correct 1 ms 348 KB Output is correct
48 Correct 1 ms 600 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 3 ms 5980 KB Output is correct
51 Correct 4 ms 5980 KB Output is correct
52 Correct 3 ms 5980 KB Output is correct
53 Correct 5 ms 5980 KB Output is correct
54 Correct 6 ms 5980 KB Output is correct
55 Correct 3 ms 5980 KB Output is correct
56 Correct 3 ms 5980 KB Output is correct
57 Correct 2 ms 348 KB Output is correct
58 Correct 3 ms 5980 KB Output is correct
59 Correct 2 ms 344 KB Output is correct
60 Correct 3 ms 5980 KB Output is correct
61 Correct 2 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 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 1 ms 348 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 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 4 ms 5980 KB Output is correct
16 Correct 3 ms 5980 KB Output is correct
17 Correct 3 ms 5980 KB Output is correct
18 Correct 3 ms 5976 KB Output is correct
19 Correct 3 ms 5980 KB Output is correct
20 Correct 3 ms 5980 KB Output is correct
21 Correct 3 ms 5980 KB Output is correct
22 Correct 3 ms 5980 KB Output is correct
23 Correct 3 ms 5988 KB Output is correct
24 Correct 41 ms 20588 KB Output is correct
25 Correct 35 ms 20572 KB Output is correct
26 Correct 34 ms 20572 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 3 ms 344 KB Output is correct
32 Correct 1 ms 344 KB Output is correct
33 Correct 0 ms 600 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 1 ms 348 KB Output is correct
36 Correct 3 ms 5212 KB Output is correct
37 Correct 3 ms 3932 KB Output is correct
38 Correct 2 ms 3420 KB Output is correct
39 Correct 4 ms 5724 KB Output is correct
40 Correct 3 ms 4700 KB Output is correct
41 Correct 3 ms 5212 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 2 ms 4700 KB Output is correct
44 Correct 1 ms 348 KB Output is correct
45 Correct 3 ms 5724 KB Output is correct
46 Correct 2 ms 5464 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 6 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 1 ms 600 KB Output is correct
52 Correct 1 ms 348 KB Output is correct
53 Correct 3 ms 5980 KB Output is correct
54 Correct 4 ms 5980 KB Output is correct
55 Correct 3 ms 5980 KB Output is correct
56 Correct 5 ms 5980 KB Output is correct
57 Correct 6 ms 5980 KB Output is correct
58 Correct 3 ms 5980 KB Output is correct
59 Correct 3 ms 5980 KB Output is correct
60 Correct 2 ms 348 KB Output is correct
61 Correct 3 ms 5980 KB Output is correct
62 Correct 2 ms 344 KB Output is correct
63 Correct 3 ms 5980 KB Output is correct
64 Correct 2 ms 348 KB Output is correct
65 Correct 31 ms 596 KB Output is correct
66 Correct 10 ms 348 KB Output is correct
67 Correct 73 ms 444 KB Output is correct
68 Correct 28 ms 348 KB Output is correct
69 Correct 60 ms 344 KB Output is correct
70 Correct 15 ms 5464 KB Output is correct
71 Correct 15 ms 4700 KB Output is correct
72 Correct 10 ms 4188 KB Output is correct
73 Correct 4 ms 4444 KB Output is correct
74 Correct 12 ms 5212 KB Output is correct
75 Correct 11 ms 6236 KB Output is correct
76 Correct 30 ms 14652 KB Output is correct
77 Correct 27 ms 17236 KB Output is correct
78 Correct 38 ms 19536 KB Output is correct
79 Correct 157 ms 348 KB Output is correct
80 Correct 156 ms 456 KB Output is correct
81 Correct 156 ms 344 KB Output is correct
82 Correct 157 ms 476 KB Output is correct
83 Correct 159 ms 492 KB Output is correct
84 Correct 24 ms 6492 KB Output is correct
85 Correct 22 ms 6744 KB Output is correct
86 Correct 23 ms 6488 KB Output is correct
87 Correct 24 ms 6492 KB Output is correct
88 Correct 23 ms 6488 KB Output is correct
89 Correct 23 ms 6488 KB Output is correct
90 Correct 50 ms 20560 KB Output is correct
91 Correct 47 ms 20564 KB Output is correct
92 Correct 47 ms 20676 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 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 1 ms 348 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 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 4 ms 5980 KB Output is correct
16 Correct 3 ms 5980 KB Output is correct
17 Correct 3 ms 5980 KB Output is correct
18 Correct 3 ms 5976 KB Output is correct
19 Correct 3 ms 5980 KB Output is correct
20 Correct 3 ms 5980 KB Output is correct
21 Correct 3 ms 5980 KB Output is correct
22 Correct 3 ms 5980 KB Output is correct
23 Correct 3 ms 5988 KB Output is correct
24 Correct 41 ms 20588 KB Output is correct
25 Correct 35 ms 20572 KB Output is correct
26 Correct 34 ms 20572 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 3 ms 604 KB Output is correct
33 Correct 587 ms 9068 KB Output is correct
34 Correct 606 ms 9216 KB Output is correct
35 Correct 600 ms 9052 KB Output is correct
36 Correct 590 ms 9284 KB Output is correct
37 Correct 602 ms 9048 KB Output is correct
38 Correct 595 ms 9252 KB Output is correct
39 Correct 269 ms 21084 KB Output is correct
40 Correct 267 ms 21080 KB Output is correct
41 Correct 267 ms 21084 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 3 ms 344 KB Output is correct
47 Correct 1 ms 344 KB Output is correct
48 Correct 0 ms 600 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 1 ms 348 KB Output is correct
51 Correct 3 ms 5212 KB Output is correct
52 Correct 3 ms 3932 KB Output is correct
53 Correct 2 ms 3420 KB Output is correct
54 Correct 4 ms 5724 KB Output is correct
55 Correct 3 ms 4700 KB Output is correct
56 Correct 3 ms 5212 KB Output is correct
57 Correct 1 ms 348 KB Output is correct
58 Correct 2 ms 4700 KB Output is correct
59 Correct 1 ms 348 KB Output is correct
60 Correct 3 ms 5724 KB Output is correct
61 Correct 2 ms 5464 KB Output is correct
62 Correct 0 ms 348 KB Output is correct
63 Correct 6 ms 348 KB Output is correct
64 Correct 1 ms 348 KB Output is correct
65 Correct 1 ms 348 KB Output is correct
66 Correct 1 ms 600 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 3 ms 5980 KB Output is correct
69 Correct 4 ms 5980 KB Output is correct
70 Correct 3 ms 5980 KB Output is correct
71 Correct 5 ms 5980 KB Output is correct
72 Correct 6 ms 5980 KB Output is correct
73 Correct 3 ms 5980 KB Output is correct
74 Correct 3 ms 5980 KB Output is correct
75 Correct 2 ms 348 KB Output is correct
76 Correct 3 ms 5980 KB Output is correct
77 Correct 2 ms 344 KB Output is correct
78 Correct 3 ms 5980 KB Output is correct
79 Correct 2 ms 348 KB Output is correct
80 Correct 31 ms 596 KB Output is correct
81 Correct 10 ms 348 KB Output is correct
82 Correct 73 ms 444 KB Output is correct
83 Correct 28 ms 348 KB Output is correct
84 Correct 60 ms 344 KB Output is correct
85 Correct 15 ms 5464 KB Output is correct
86 Correct 15 ms 4700 KB Output is correct
87 Correct 10 ms 4188 KB Output is correct
88 Correct 4 ms 4444 KB Output is correct
89 Correct 12 ms 5212 KB Output is correct
90 Correct 11 ms 6236 KB Output is correct
91 Correct 30 ms 14652 KB Output is correct
92 Correct 27 ms 17236 KB Output is correct
93 Correct 38 ms 19536 KB Output is correct
94 Correct 157 ms 348 KB Output is correct
95 Correct 156 ms 456 KB Output is correct
96 Correct 156 ms 344 KB Output is correct
97 Correct 157 ms 476 KB Output is correct
98 Correct 159 ms 492 KB Output is correct
99 Correct 24 ms 6492 KB Output is correct
100 Correct 22 ms 6744 KB Output is correct
101 Correct 23 ms 6488 KB Output is correct
102 Correct 24 ms 6492 KB Output is correct
103 Correct 23 ms 6488 KB Output is correct
104 Correct 23 ms 6488 KB Output is correct
105 Correct 50 ms 20560 KB Output is correct
106 Correct 47 ms 20564 KB Output is correct
107 Correct 47 ms 20676 KB Output is correct
108 Correct 3 ms 600 KB Output is correct
109 Execution timed out 1514 ms 612 KB Time limit exceeded
110 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 0 ms 344 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 1 ms 348 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 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 4 ms 5980 KB Output is correct
16 Correct 3 ms 5980 KB Output is correct
17 Correct 3 ms 5980 KB Output is correct
18 Correct 3 ms 5976 KB Output is correct
19 Correct 3 ms 5980 KB Output is correct
20 Correct 3 ms 5980 KB Output is correct
21 Correct 3 ms 5980 KB Output is correct
22 Correct 3 ms 5980 KB Output is correct
23 Correct 3 ms 5988 KB Output is correct
24 Correct 41 ms 20588 KB Output is correct
25 Correct 35 ms 20572 KB Output is correct
26 Correct 34 ms 20572 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 600 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 604 KB Output is correct
31 Correct 2 ms 604 KB Output is correct
32 Correct 3 ms 604 KB Output is correct
33 Correct 587 ms 9068 KB Output is correct
34 Correct 606 ms 9216 KB Output is correct
35 Correct 600 ms 9052 KB Output is correct
36 Correct 590 ms 9284 KB Output is correct
37 Correct 602 ms 9048 KB Output is correct
38 Correct 595 ms 9252 KB Output is correct
39 Correct 269 ms 21084 KB Output is correct
40 Correct 267 ms 21080 KB Output is correct
41 Correct 267 ms 21084 KB Output is correct
42 Correct 7 ms 1372 KB Output is correct
43 Correct 5 ms 1112 KB Output is correct
44 Correct 10 ms 1600 KB Output is correct
45 Correct 7 ms 1116 KB Output is correct
46 Correct 7 ms 1116 KB Output is correct
47 Correct 11 ms 1372 KB Output is correct
48 Execution timed out 1565 ms 24660 KB Time limit exceeded
49 Halted 0 ms 0 KB -