Submission #393250

# Submission time Handle Problem Language Result Execution time Memory
393250 2021-04-23T04:54:41 Z anime Painting Walls (APIO20_paint) C++14
51 / 100
395 ms 196844 KB
//#include "grader.cpp"
#include "paint.h"
#include <bits/stdc++.h>
#define pb push_back
#define pii pair<int,int>
#define fr first
#define sc second
#define OK puts("OK");
#define endi puts("");
#define ret return
#define all(s) s.begin(),s.end()
using namespace std;
const int N = 1e5+5,INF = 1e9+7;
vector <int> v[N],c;
int n,m,k;
bitset <2000> can[N];
int p[N],dp[20000][2000];

bool is(int l,int r){
	int i,x = r-l+1;
	for (i=0;i<m;++i){
		if (l == 0){
			if (dp[r][i] == x)ret 1;
		}
		else {
			int y = dp[r][i]-dp[l-1][i];
			if (y == x)ret 1;
		}
	}
	ret 0;
}

int minimumInstructions(int N, int M, int K,vector<int> C,vector<int> A, vector<vector<int>> B){
	c = C;n=N;m=M;k=K;
	
    int i,j,ans=0;
    for (i=0;i<m;++i)
        for (int x: B[i])
			can[x][i] = 1;
	
	for (i=0;i<n;++i){
		if (i > 0)
			for (j=0;j<m;++j){
				int x = j-1;
				x+=m;
				x%=m;
				dp[i][j] = dp[i-1][x];
			}
		for (j=0;j<m;++j)
			if (can[c[i]][j] == 1)
				dp[i][j]++;
	}
	for (i=0;i<n-m+1;++i)
		p[i] = is(i,i+m-1);
	int pos = 0,z=1;
	while (pos >= 0 && pos < n && z>0){
		if (p[pos] == 1){
			pos +=m;
			ans++;
			z= m;
		}
		else {
			pos--;
			z--;
		}
	}
	if (pos < n)ans= -1;
	ret ans;


}





Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:37:5: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   37 |     for (i=0;i<m;++i)
      |     ^~~
paint.cpp:41:2: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   41 |  for (i=0;i<n;++i){
      |  ^~~
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2656 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 3 ms 4556 KB Output is correct
8 Correct 3 ms 4576 KB Output is correct
9 Correct 3 ms 4684 KB Output is correct
10 Correct 3 ms 4580 KB Output is correct
11 Correct 3 ms 4684 KB Output is correct
12 Correct 3 ms 4684 KB Output is correct
13 Correct 5 ms 6988 KB Output is correct
14 Correct 4 ms 6988 KB Output is correct
15 Correct 4 ms 6992 KB Output is correct
16 Correct 4 ms 6988 KB Output is correct
17 Correct 4 ms 6988 KB Output is correct
18 Correct 4 ms 6992 KB Output is correct
19 Correct 6 ms 8780 KB Output is correct
20 Correct 5 ms 8800 KB Output is correct
21 Correct 5 ms 8780 KB Output is correct
22 Correct 26 ms 31444 KB Output is correct
23 Correct 26 ms 31444 KB Output is correct
24 Correct 26 ms 31460 KB Output is correct
25 Correct 36 ms 83288 KB Output is correct
26 Correct 36 ms 83300 KB Output is correct
27 Correct 36 ms 83236 KB Output is correct
28 Correct 35 ms 83180 KB Output is correct
29 Correct 35 ms 83276 KB Output is correct
30 Correct 35 ms 83176 KB Output is correct
31 Correct 362 ms 184268 KB Output is correct
32 Correct 358 ms 184408 KB Output is correct
33 Correct 360 ms 184420 KB Output is correct
34 Correct 363 ms 184416 KB Output is correct
35 Correct 361 ms 184368 KB Output is correct
36 Correct 361 ms 184296 KB Output is correct
37 Correct 373 ms 186080 KB Output is correct
38 Correct 375 ms 186180 KB Output is correct
39 Correct 380 ms 186308 KB Output is correct
40 Runtime error 311 ms 196844 KB Execution killed with signal 11
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2656 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 3 ms 4556 KB Output is correct
8 Correct 3 ms 4576 KB Output is correct
9 Correct 3 ms 4684 KB Output is correct
10 Correct 3 ms 4580 KB Output is correct
11 Correct 3 ms 4684 KB Output is correct
12 Correct 3 ms 4684 KB Output is correct
13 Correct 5 ms 6988 KB Output is correct
14 Correct 4 ms 6988 KB Output is correct
15 Correct 4 ms 6992 KB Output is correct
16 Correct 4 ms 6988 KB Output is correct
17 Correct 4 ms 6988 KB Output is correct
18 Correct 4 ms 6992 KB Output is correct
19 Correct 6 ms 8780 KB Output is correct
20 Correct 5 ms 8800 KB Output is correct
21 Correct 5 ms 8780 KB Output is correct
22 Correct 2 ms 2640 KB Output is correct
23 Correct 2 ms 2636 KB Output is correct
24 Correct 2 ms 2652 KB Output is correct
25 Correct 2 ms 2636 KB Output is correct
26 Correct 2 ms 2636 KB Output is correct
27 Correct 2 ms 3788 KB Output is correct
28 Correct 3 ms 3936 KB Output is correct
29 Correct 3 ms 3676 KB Output is correct
30 Correct 3 ms 4044 KB Output is correct
31 Correct 2 ms 4428 KB Output is correct
32 Correct 3 ms 4172 KB Output is correct
33 Correct 4 ms 6092 KB Output is correct
34 Correct 4 ms 6348 KB Output is correct
35 Correct 4 ms 5196 KB Output is correct
36 Correct 4 ms 5836 KB Output is correct
37 Correct 4 ms 5580 KB Output is correct
38 Correct 4 ms 7244 KB Output is correct
39 Correct 2 ms 3916 KB Output is correct
40 Correct 5 ms 7596 KB Output is correct
41 Correct 3 ms 4172 KB Output is correct
42 Correct 4 ms 7116 KB Output is correct
43 Correct 3 ms 5196 KB Output is correct
44 Correct 3 ms 4684 KB Output is correct
45 Correct 3 ms 4696 KB Output is correct
46 Correct 3 ms 4684 KB Output is correct
47 Correct 3 ms 4684 KB Output is correct
48 Correct 3 ms 4684 KB Output is correct
49 Correct 3 ms 4684 KB Output is correct
50 Correct 4 ms 6988 KB Output is correct
51 Correct 5 ms 6988 KB Output is correct
52 Correct 4 ms 7012 KB Output is correct
53 Correct 4 ms 6988 KB Output is correct
54 Correct 4 ms 6988 KB Output is correct
55 Correct 5 ms 6988 KB Output is correct
56 Correct 6 ms 8780 KB Output is correct
57 Correct 4 ms 5092 KB Output is correct
58 Correct 6 ms 8652 KB Output is correct
59 Correct 4 ms 5196 KB Output is correct
60 Correct 5 ms 8652 KB Output is correct
61 Correct 4 ms 5196 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2656 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 3 ms 4556 KB Output is correct
10 Correct 3 ms 4576 KB Output is correct
11 Correct 3 ms 4684 KB Output is correct
12 Correct 3 ms 4580 KB Output is correct
13 Correct 3 ms 4684 KB Output is correct
14 Correct 3 ms 4684 KB Output is correct
15 Correct 5 ms 6988 KB Output is correct
16 Correct 4 ms 6988 KB Output is correct
17 Correct 4 ms 6992 KB Output is correct
18 Correct 4 ms 6988 KB Output is correct
19 Correct 4 ms 6988 KB Output is correct
20 Correct 4 ms 6992 KB Output is correct
21 Correct 6 ms 8780 KB Output is correct
22 Correct 5 ms 8800 KB Output is correct
23 Correct 5 ms 8780 KB Output is correct
24 Correct 26 ms 31444 KB Output is correct
25 Correct 26 ms 31444 KB Output is correct
26 Correct 26 ms 31460 KB Output is correct
27 Correct 2 ms 2652 KB Output is correct
28 Correct 2 ms 2636 KB Output is correct
29 Correct 2 ms 2636 KB Output is correct
30 Correct 2 ms 3788 KB Output is correct
31 Correct 3 ms 3936 KB Output is correct
32 Correct 3 ms 3676 KB Output is correct
33 Correct 3 ms 4044 KB Output is correct
34 Correct 2 ms 4428 KB Output is correct
35 Correct 3 ms 4172 KB Output is correct
36 Correct 4 ms 6092 KB Output is correct
37 Correct 4 ms 6348 KB Output is correct
38 Correct 4 ms 5196 KB Output is correct
39 Correct 4 ms 5836 KB Output is correct
40 Correct 4 ms 5580 KB Output is correct
41 Correct 4 ms 7244 KB Output is correct
42 Correct 2 ms 3916 KB Output is correct
43 Correct 5 ms 7596 KB Output is correct
44 Correct 3 ms 4172 KB Output is correct
45 Correct 4 ms 7116 KB Output is correct
46 Correct 3 ms 5196 KB Output is correct
47 Correct 3 ms 4684 KB Output is correct
48 Correct 3 ms 4696 KB Output is correct
49 Correct 3 ms 4684 KB Output is correct
50 Correct 3 ms 4684 KB Output is correct
51 Correct 3 ms 4684 KB Output is correct
52 Correct 3 ms 4684 KB Output is correct
53 Correct 4 ms 6988 KB Output is correct
54 Correct 5 ms 6988 KB Output is correct
55 Correct 4 ms 7012 KB Output is correct
56 Correct 4 ms 6988 KB Output is correct
57 Correct 4 ms 6988 KB Output is correct
58 Correct 5 ms 6988 KB Output is correct
59 Correct 6 ms 8780 KB Output is correct
60 Correct 4 ms 5092 KB Output is correct
61 Correct 6 ms 8652 KB Output is correct
62 Correct 4 ms 5196 KB Output is correct
63 Correct 5 ms 8652 KB Output is correct
64 Correct 4 ms 5196 KB Output is correct
65 Correct 3 ms 3808 KB Output is correct
66 Correct 3 ms 4556 KB Output is correct
67 Correct 3 ms 4812 KB Output is correct
68 Correct 3 ms 4684 KB Output is correct
69 Correct 3 ms 4684 KB Output is correct
70 Correct 6 ms 6476 KB Output is correct
71 Correct 5 ms 6348 KB Output is correct
72 Correct 5 ms 5964 KB Output is correct
73 Correct 4 ms 5740 KB Output is correct
74 Correct 5 ms 5612 KB Output is correct
75 Correct 5 ms 5708 KB Output is correct
76 Correct 24 ms 22852 KB Output is correct
77 Correct 26 ms 27332 KB Output is correct
78 Correct 30 ms 30152 KB Output is correct
79 Correct 4 ms 5048 KB Output is correct
80 Correct 4 ms 5068 KB Output is correct
81 Correct 3 ms 5068 KB Output is correct
82 Correct 4 ms 5068 KB Output is correct
83 Correct 4 ms 5068 KB Output is correct
84 Correct 7 ms 7144 KB Output is correct
85 Correct 6 ms 7112 KB Output is correct
86 Correct 6 ms 7116 KB Output is correct
87 Correct 7 ms 7116 KB Output is correct
88 Correct 6 ms 7120 KB Output is correct
89 Correct 7 ms 7116 KB Output is correct
90 Correct 33 ms 32168 KB Output is correct
91 Correct 32 ms 32144 KB Output is correct
92 Correct 33 ms 32192 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2656 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 3 ms 4556 KB Output is correct
10 Correct 3 ms 4576 KB Output is correct
11 Correct 3 ms 4684 KB Output is correct
12 Correct 3 ms 4580 KB Output is correct
13 Correct 3 ms 4684 KB Output is correct
14 Correct 3 ms 4684 KB Output is correct
15 Correct 5 ms 6988 KB Output is correct
16 Correct 4 ms 6988 KB Output is correct
17 Correct 4 ms 6992 KB Output is correct
18 Correct 4 ms 6988 KB Output is correct
19 Correct 4 ms 6988 KB Output is correct
20 Correct 4 ms 6992 KB Output is correct
21 Correct 6 ms 8780 KB Output is correct
22 Correct 5 ms 8800 KB Output is correct
23 Correct 5 ms 8780 KB Output is correct
24 Correct 26 ms 31444 KB Output is correct
25 Correct 26 ms 31444 KB Output is correct
26 Correct 26 ms 31460 KB Output is correct
27 Correct 36 ms 83288 KB Output is correct
28 Correct 36 ms 83300 KB Output is correct
29 Correct 36 ms 83236 KB Output is correct
30 Correct 35 ms 83180 KB Output is correct
31 Correct 35 ms 83276 KB Output is correct
32 Correct 35 ms 83176 KB Output is correct
33 Correct 362 ms 184268 KB Output is correct
34 Correct 358 ms 184408 KB Output is correct
35 Correct 360 ms 184420 KB Output is correct
36 Correct 363 ms 184416 KB Output is correct
37 Correct 361 ms 184368 KB Output is correct
38 Correct 361 ms 184296 KB Output is correct
39 Correct 373 ms 186080 KB Output is correct
40 Correct 375 ms 186180 KB Output is correct
41 Correct 380 ms 186308 KB Output is correct
42 Correct 2 ms 2652 KB Output is correct
43 Correct 2 ms 2636 KB Output is correct
44 Correct 2 ms 2636 KB Output is correct
45 Correct 2 ms 3788 KB Output is correct
46 Correct 3 ms 3936 KB Output is correct
47 Correct 3 ms 3676 KB Output is correct
48 Correct 3 ms 4044 KB Output is correct
49 Correct 2 ms 4428 KB Output is correct
50 Correct 3 ms 4172 KB Output is correct
51 Correct 4 ms 6092 KB Output is correct
52 Correct 4 ms 6348 KB Output is correct
53 Correct 4 ms 5196 KB Output is correct
54 Correct 4 ms 5836 KB Output is correct
55 Correct 4 ms 5580 KB Output is correct
56 Correct 4 ms 7244 KB Output is correct
57 Correct 2 ms 3916 KB Output is correct
58 Correct 5 ms 7596 KB Output is correct
59 Correct 3 ms 4172 KB Output is correct
60 Correct 4 ms 7116 KB Output is correct
61 Correct 3 ms 5196 KB Output is correct
62 Correct 3 ms 4684 KB Output is correct
63 Correct 3 ms 4696 KB Output is correct
64 Correct 3 ms 4684 KB Output is correct
65 Correct 3 ms 4684 KB Output is correct
66 Correct 3 ms 4684 KB Output is correct
67 Correct 3 ms 4684 KB Output is correct
68 Correct 4 ms 6988 KB Output is correct
69 Correct 5 ms 6988 KB Output is correct
70 Correct 4 ms 7012 KB Output is correct
71 Correct 4 ms 6988 KB Output is correct
72 Correct 4 ms 6988 KB Output is correct
73 Correct 5 ms 6988 KB Output is correct
74 Correct 6 ms 8780 KB Output is correct
75 Correct 4 ms 5092 KB Output is correct
76 Correct 6 ms 8652 KB Output is correct
77 Correct 4 ms 5196 KB Output is correct
78 Correct 5 ms 8652 KB Output is correct
79 Correct 4 ms 5196 KB Output is correct
80 Correct 3 ms 3808 KB Output is correct
81 Correct 3 ms 4556 KB Output is correct
82 Correct 3 ms 4812 KB Output is correct
83 Correct 3 ms 4684 KB Output is correct
84 Correct 3 ms 4684 KB Output is correct
85 Correct 6 ms 6476 KB Output is correct
86 Correct 5 ms 6348 KB Output is correct
87 Correct 5 ms 5964 KB Output is correct
88 Correct 4 ms 5740 KB Output is correct
89 Correct 5 ms 5612 KB Output is correct
90 Correct 5 ms 5708 KB Output is correct
91 Correct 24 ms 22852 KB Output is correct
92 Correct 26 ms 27332 KB Output is correct
93 Correct 30 ms 30152 KB Output is correct
94 Correct 4 ms 5048 KB Output is correct
95 Correct 4 ms 5068 KB Output is correct
96 Correct 3 ms 5068 KB Output is correct
97 Correct 4 ms 5068 KB Output is correct
98 Correct 4 ms 5068 KB Output is correct
99 Correct 7 ms 7144 KB Output is correct
100 Correct 6 ms 7112 KB Output is correct
101 Correct 6 ms 7116 KB Output is correct
102 Correct 7 ms 7116 KB Output is correct
103 Correct 6 ms 7120 KB Output is correct
104 Correct 7 ms 7116 KB Output is correct
105 Correct 33 ms 32168 KB Output is correct
106 Correct 32 ms 32144 KB Output is correct
107 Correct 33 ms 32192 KB Output is correct
108 Correct 35 ms 82756 KB Output is correct
109 Correct 99 ms 95572 KB Output is correct
110 Correct 101 ms 83000 KB Output is correct
111 Correct 107 ms 79528 KB Output is correct
112 Correct 154 ms 107944 KB Output is correct
113 Correct 136 ms 85936 KB Output is correct
114 Correct 132 ms 111168 KB Output is correct
115 Correct 42 ms 65428 KB Output is correct
116 Correct 164 ms 150888 KB Output is correct
117 Correct 103 ms 92612 KB Output is correct
118 Correct 52 ms 78676 KB Output is correct
119 Correct 214 ms 137772 KB Output is correct
120 Correct 227 ms 112492 KB Output is correct
121 Correct 204 ms 98716 KB Output is correct
122 Correct 102 ms 89796 KB Output is correct
123 Correct 81 ms 76864 KB Output is correct
124 Correct 89 ms 110184 KB Output is correct
125 Correct 66 ms 93508 KB Output is correct
126 Correct 41 ms 80708 KB Output is correct
127 Correct 137 ms 136004 KB Output is correct
128 Correct 54 ms 82244 KB Output is correct
129 Correct 61 ms 82480 KB Output is correct
130 Correct 37 ms 83220 KB Output is correct
131 Correct 136 ms 132036 KB Output is correct
132 Correct 200 ms 145792 KB Output is correct
133 Correct 234 ms 153352 KB Output is correct
134 Correct 266 ms 159684 KB Output is correct
135 Correct 281 ms 159668 KB Output is correct
136 Correct 367 ms 185324 KB Output is correct
137 Correct 362 ms 185140 KB Output is correct
138 Correct 362 ms 185284 KB Output is correct
139 Correct 369 ms 185152 KB Output is correct
140 Correct 365 ms 185424 KB Output is correct
141 Correct 375 ms 185288 KB Output is correct
142 Correct 395 ms 186824 KB Output is correct
143 Correct 352 ms 164900 KB Output is correct
144 Correct 387 ms 186932 KB Output is correct
145 Correct 349 ms 164976 KB Output is correct
146 Correct 382 ms 186984 KB Output is correct
147 Correct 353 ms 165032 KB Output is correct
148 Correct 377 ms 184608 KB Output is correct
149 Correct 229 ms 184516 KB Output is correct
150 Correct 172 ms 159320 KB Output is correct
151 Correct 145 ms 146760 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2640 KB Output is correct
2 Correct 2 ms 2636 KB Output is correct
3 Correct 2 ms 2636 KB Output is correct
4 Correct 2 ms 2636 KB Output is correct
5 Correct 2 ms 2636 KB Output is correct
6 Correct 2 ms 2636 KB Output is correct
7 Correct 2 ms 2656 KB Output is correct
8 Correct 2 ms 2636 KB Output is correct
9 Correct 3 ms 4556 KB Output is correct
10 Correct 3 ms 4576 KB Output is correct
11 Correct 3 ms 4684 KB Output is correct
12 Correct 3 ms 4580 KB Output is correct
13 Correct 3 ms 4684 KB Output is correct
14 Correct 3 ms 4684 KB Output is correct
15 Correct 5 ms 6988 KB Output is correct
16 Correct 4 ms 6988 KB Output is correct
17 Correct 4 ms 6992 KB Output is correct
18 Correct 4 ms 6988 KB Output is correct
19 Correct 4 ms 6988 KB Output is correct
20 Correct 4 ms 6992 KB Output is correct
21 Correct 6 ms 8780 KB Output is correct
22 Correct 5 ms 8800 KB Output is correct
23 Correct 5 ms 8780 KB Output is correct
24 Correct 26 ms 31444 KB Output is correct
25 Correct 26 ms 31444 KB Output is correct
26 Correct 26 ms 31460 KB Output is correct
27 Correct 36 ms 83288 KB Output is correct
28 Correct 36 ms 83300 KB Output is correct
29 Correct 36 ms 83236 KB Output is correct
30 Correct 35 ms 83180 KB Output is correct
31 Correct 35 ms 83276 KB Output is correct
32 Correct 35 ms 83176 KB Output is correct
33 Correct 362 ms 184268 KB Output is correct
34 Correct 358 ms 184408 KB Output is correct
35 Correct 360 ms 184420 KB Output is correct
36 Correct 363 ms 184416 KB Output is correct
37 Correct 361 ms 184368 KB Output is correct
38 Correct 361 ms 184296 KB Output is correct
39 Correct 373 ms 186080 KB Output is correct
40 Correct 375 ms 186180 KB Output is correct
41 Correct 380 ms 186308 KB Output is correct
42 Runtime error 311 ms 196844 KB Execution killed with signal 11
43 Halted 0 ms 0 KB -