Submission #290690

# Submission time Handle Problem Language Result Execution time Memory
290690 2020-09-04T10:34:51 Z TadijaSebez Painting Walls (APIO20_paint) C++11
12 / 100
89 ms 17328 KB
#include "paint.h"
#include <bits/stdc++.h>
using namespace std;
#define pii pair<int,int>
#define pb push_back

int minimumInstructions(int n,int m,int k,vector<int> c,vector<int> a,vector<vector<int>> b){
	vector<set<int>> can(k);
	for(int i=0;i<m;i++)for(int j=0;j<a[i];j++)can[b[i][j]].insert(i);
	vector<int> r(n,0),l(n,0);
	for(int i=0;i<n;i++){
		while(i+r[i]<n&&can[c[i+r[i]]].count(r[i]))r[i]++;
		while(i-l[i]>=0&&can[c[i-l[i]]].count(m-l[i]-1))l[i]++;
		//printf("%i %i %i\n",i,l[i],r[i]);
	}
	vector<bool> seg(n,0);
	for(int i=0;i<n-1;i++){
		if(l[i]+r[i+1]>=m){
			int sz=l[i]+r[i+1]-m+1;
			for(int j=1;j<=sz;j++)seg[i-l[i]+j]=1;
		}
	}
	if(r[n-1]==m)seg[n-1]=1;
	vector<pii> ans;
	ans.pb({-1,-1});
	for(int i=0;i<n;i++){
		if(seg[i]){
			int sz=ans.size();
			if(sz>1&&ans[sz-2].second+1>=i)ans.pop_back();
			if(ans.back().second+1<i)return -1;
			ans.pb({i,i+m-1});
			//printf("%i %i\n",i,i+m-1);
		}
	}
	if(ans.back().second<n-1)return -1;
	return ans.size()-1;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 384 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 0 ms 256 KB Output is correct
4 Correct 1 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 1 ms 384 KB Output is correct
8 Correct 1 ms 384 KB Output is correct
9 Correct 0 ms 256 KB Output is correct
10 Correct 1 ms 256 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 4 ms 5120 KB Output is correct
14 Correct 4 ms 5120 KB Output is correct
15 Correct 4 ms 5120 KB Output is correct
16 Correct 4 ms 5120 KB Output is correct
17 Correct 4 ms 5120 KB Output is correct
18 Correct 4 ms 5120 KB Output is correct
19 Correct 4 ms 5120 KB Output is correct
20 Correct 4 ms 5120 KB Output is correct
21 Correct 4 ms 5120 KB Output is correct
22 Correct 37 ms 10488 KB Output is correct
23 Correct 36 ms 10472 KB Output is correct
24 Correct 36 ms 10488 KB Output is correct
25 Correct 3 ms 1024 KB Output is correct
26 Correct 4 ms 1024 KB Output is correct
27 Correct 3 ms 640 KB Output is correct
28 Correct 3 ms 640 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 16 ms 6528 KB Output is correct
32 Correct 15 ms 6528 KB Output is correct
33 Correct 15 ms 6528 KB Output is correct
34 Correct 15 ms 6528 KB Output is correct
35 Correct 15 ms 6528 KB Output is correct
36 Correct 15 ms 6656 KB Output is correct
37 Correct 48 ms 11000 KB Output is correct
38 Correct 43 ms 11000 KB Output is correct
39 Correct 47 ms 11128 KB Output is correct
40 Correct 15 ms 2936 KB Output is correct
41 Correct 9 ms 1916 KB Output is correct
42 Correct 15 ms 1920 KB Output is correct
43 Correct 9 ms 1408 KB Output is correct
44 Correct 9 ms 1280 KB Output is correct
45 Correct 14 ms 1920 KB Output is correct
46 Correct 72 ms 16120 KB Output is correct
47 Correct 42 ms 10840 KB Output is correct
48 Correct 54 ms 13004 KB Output is correct
49 Correct 61 ms 13944 KB Output is correct
50 Correct 64 ms 13688 KB Output is correct
51 Correct 50 ms 10496 KB Output is correct
52 Correct 15 ms 3064 KB Output is correct
53 Correct 15 ms 3064 KB Output is correct
54 Correct 16 ms 1920 KB Output is correct
55 Correct 14 ms 1920 KB Output is correct
56 Correct 15 ms 1920 KB Output is correct
57 Correct 13 ms 1920 KB Output is correct
58 Correct 88 ms 17144 KB Output is correct
59 Correct 88 ms 17144 KB Output is correct
60 Correct 84 ms 17328 KB Output is correct
61 Correct 86 ms 17272 KB Output is correct
62 Correct 89 ms 17144 KB Output is correct
63 Correct 82 ms 17176 KB Output is correct
64 Correct 88 ms 16504 KB Output is correct
65 Correct 85 ms 16376 KB Output is correct
66 Correct 81 ms 16376 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 4 ms 5120 KB Output is correct
16 Correct 4 ms 5120 KB Output is correct
17 Correct 4 ms 5120 KB Output is correct
18 Correct 4 ms 5120 KB Output is correct
19 Correct 4 ms 5120 KB Output is correct
20 Correct 4 ms 5120 KB Output is correct
21 Correct 4 ms 5120 KB Output is correct
22 Correct 4 ms 5120 KB Output is correct
23 Correct 4 ms 5120 KB Output is correct
24 Correct 0 ms 256 KB Output is correct
25 Correct 0 ms 256 KB Output is correct
26 Incorrect 1 ms 384 KB Output isn't correct
27 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 4 ms 5120 KB Output is correct
16 Correct 4 ms 5120 KB Output is correct
17 Correct 4 ms 5120 KB Output is correct
18 Correct 4 ms 5120 KB Output is correct
19 Correct 4 ms 5120 KB Output is correct
20 Correct 4 ms 5120 KB Output is correct
21 Correct 4 ms 5120 KB Output is correct
22 Correct 4 ms 5120 KB Output is correct
23 Correct 4 ms 5120 KB Output is correct
24 Correct 37 ms 10488 KB Output is correct
25 Correct 36 ms 10472 KB Output is correct
26 Correct 36 ms 10488 KB Output is correct
27 Correct 0 ms 256 KB Output is correct
28 Correct 0 ms 256 KB Output is correct
29 Incorrect 1 ms 384 KB Output isn't correct
30 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 4 ms 5120 KB Output is correct
16 Correct 4 ms 5120 KB Output is correct
17 Correct 4 ms 5120 KB Output is correct
18 Correct 4 ms 5120 KB Output is correct
19 Correct 4 ms 5120 KB Output is correct
20 Correct 4 ms 5120 KB Output is correct
21 Correct 4 ms 5120 KB Output is correct
22 Correct 4 ms 5120 KB Output is correct
23 Correct 4 ms 5120 KB Output is correct
24 Correct 37 ms 10488 KB Output is correct
25 Correct 36 ms 10472 KB Output is correct
26 Correct 36 ms 10488 KB Output is correct
27 Correct 3 ms 1024 KB Output is correct
28 Correct 4 ms 1024 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 3 ms 640 KB Output is correct
32 Correct 3 ms 640 KB Output is correct
33 Correct 16 ms 6528 KB Output is correct
34 Correct 15 ms 6528 KB Output is correct
35 Correct 15 ms 6528 KB Output is correct
36 Correct 15 ms 6528 KB Output is correct
37 Correct 15 ms 6528 KB Output is correct
38 Correct 15 ms 6656 KB Output is correct
39 Correct 48 ms 11000 KB Output is correct
40 Correct 43 ms 11000 KB Output is correct
41 Correct 47 ms 11128 KB Output is correct
42 Correct 0 ms 256 KB Output is correct
43 Correct 0 ms 256 KB Output is correct
44 Incorrect 1 ms 384 KB Output isn't correct
45 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 256 KB Output is correct
2 Correct 0 ms 256 KB Output is correct
3 Correct 1 ms 384 KB Output is correct
4 Correct 0 ms 256 KB Output is correct
5 Correct 0 ms 256 KB Output is correct
6 Correct 1 ms 256 KB Output is correct
7 Correct 0 ms 256 KB Output is correct
8 Correct 1 ms 256 KB Output is correct
9 Correct 1 ms 384 KB Output is correct
10 Correct 1 ms 384 KB Output is correct
11 Correct 0 ms 256 KB Output is correct
12 Correct 1 ms 256 KB Output is correct
13 Correct 0 ms 256 KB Output is correct
14 Correct 1 ms 256 KB Output is correct
15 Correct 4 ms 5120 KB Output is correct
16 Correct 4 ms 5120 KB Output is correct
17 Correct 4 ms 5120 KB Output is correct
18 Correct 4 ms 5120 KB Output is correct
19 Correct 4 ms 5120 KB Output is correct
20 Correct 4 ms 5120 KB Output is correct
21 Correct 4 ms 5120 KB Output is correct
22 Correct 4 ms 5120 KB Output is correct
23 Correct 4 ms 5120 KB Output is correct
24 Correct 37 ms 10488 KB Output is correct
25 Correct 36 ms 10472 KB Output is correct
26 Correct 36 ms 10488 KB Output is correct
27 Correct 3 ms 1024 KB Output is correct
28 Correct 4 ms 1024 KB Output is correct
29 Correct 3 ms 640 KB Output is correct
30 Correct 3 ms 640 KB Output is correct
31 Correct 3 ms 640 KB Output is correct
32 Correct 3 ms 640 KB Output is correct
33 Correct 16 ms 6528 KB Output is correct
34 Correct 15 ms 6528 KB Output is correct
35 Correct 15 ms 6528 KB Output is correct
36 Correct 15 ms 6528 KB Output is correct
37 Correct 15 ms 6528 KB Output is correct
38 Correct 15 ms 6656 KB Output is correct
39 Correct 48 ms 11000 KB Output is correct
40 Correct 43 ms 11000 KB Output is correct
41 Correct 47 ms 11128 KB Output is correct
42 Correct 15 ms 2936 KB Output is correct
43 Correct 9 ms 1916 KB Output is correct
44 Correct 15 ms 1920 KB Output is correct
45 Correct 9 ms 1408 KB Output is correct
46 Correct 9 ms 1280 KB Output is correct
47 Correct 14 ms 1920 KB Output is correct
48 Correct 72 ms 16120 KB Output is correct
49 Correct 42 ms 10840 KB Output is correct
50 Correct 54 ms 13004 KB Output is correct
51 Correct 61 ms 13944 KB Output is correct
52 Correct 64 ms 13688 KB Output is correct
53 Correct 50 ms 10496 KB Output is correct
54 Correct 15 ms 3064 KB Output is correct
55 Correct 15 ms 3064 KB Output is correct
56 Correct 16 ms 1920 KB Output is correct
57 Correct 14 ms 1920 KB Output is correct
58 Correct 15 ms 1920 KB Output is correct
59 Correct 13 ms 1920 KB Output is correct
60 Correct 88 ms 17144 KB Output is correct
61 Correct 88 ms 17144 KB Output is correct
62 Correct 84 ms 17328 KB Output is correct
63 Correct 86 ms 17272 KB Output is correct
64 Correct 89 ms 17144 KB Output is correct
65 Correct 82 ms 17176 KB Output is correct
66 Correct 88 ms 16504 KB Output is correct
67 Correct 85 ms 16376 KB Output is correct
68 Correct 81 ms 16376 KB Output is correct
69 Correct 0 ms 256 KB Output is correct
70 Correct 0 ms 256 KB Output is correct
71 Incorrect 1 ms 384 KB Output isn't correct
72 Halted 0 ms 0 KB -