Submission #965925

# Submission time Handle Problem Language Result Execution time Memory
965925 2024-04-19T08:00:05 Z willychan Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 2648 KB
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int minimumInstructions(int N, int M, int K, std::vector<int> C,std::vector<int> A, std::vector<std::vector<int>> B) {
  vector<int> ok(N,0);
  for(int i=0;i<=N-M;i++){
	for(int j=0;j<M;j++){
  		bool work=1;
		for(int k=0;k<M;k++){
			int f = lower_bound(B[(j+k)%M].begin(),B[(j+k)%M].end(),C[i+k])-B[(j+k)%M].begin();
			work&=(f<A[(j+k)%M] && B[(j+k)%M][f]==C[i+k]);
		}
		if(work){
			ok[i]=1;
			break;
		}
	}
  }
  int cur = 0;
  int ans = 0;
  vector<bool> colored(N,0);
  int maxn = -1e9;
  for(int i=0;i<N;i++){
  	if(ok[i]) maxn = max(maxn,i);
	if(!colored[i]){
		ans++;
		int k = maxn+M-1;
		if(k<i) return -1;
		for(int h=i;h<=k;h++) colored[h]=1;
	}
  }
  return 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:21:7: warning: unused variable 'cur' [-Wunused-variable]
   21 |   int cur = 0;
      |       ^~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 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 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 600 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 82 ms 444 KB Output is correct
14 Correct 87 ms 348 KB Output is correct
15 Correct 92 ms 348 KB Output is correct
16 Correct 91 ms 348 KB Output is correct
17 Correct 94 ms 348 KB Output is correct
18 Correct 93 ms 348 KB Output is correct
19 Correct 236 ms 344 KB Output is correct
20 Correct 237 ms 448 KB Output is correct
21 Correct 238 ms 348 KB Output is correct
22 Correct 738 ms 1876 KB Output is correct
23 Correct 717 ms 1880 KB Output is correct
24 Correct 719 ms 1792 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 708 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 3 ms 604 KB Output is correct
29 Correct 4 ms 600 KB Output is correct
30 Correct 5 ms 600 KB Output is correct
31 Execution timed out 1539 ms 1368 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 348 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 344 KB Output is correct
8 Correct 1 ms 348 KB Output is correct
9 Correct 0 ms 600 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 82 ms 444 KB Output is correct
14 Correct 87 ms 348 KB Output is correct
15 Correct 92 ms 348 KB Output is correct
16 Correct 91 ms 348 KB Output is correct
17 Correct 94 ms 348 KB Output is correct
18 Correct 93 ms 348 KB Output is correct
19 Correct 236 ms 344 KB Output is correct
20 Correct 237 ms 448 KB Output is correct
21 Correct 238 ms 348 KB Output is correct
22 Correct 1 ms 348 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 1 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 1 ms 348 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 2 ms 428 KB Output is correct
30 Correct 3 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 6 ms 604 KB Output is correct
33 Correct 43 ms 348 KB Output is correct
34 Correct 49 ms 344 KB Output is correct
35 Correct 17 ms 348 KB Output is correct
36 Correct 34 ms 436 KB Output is correct
37 Correct 29 ms 348 KB Output is correct
38 Correct 1 ms 344 KB Output is correct
39 Correct 1 ms 348 KB Output is correct
40 Correct 90 ms 600 KB Output is correct
41 Correct 25 ms 348 KB Output is correct
42 Correct 56 ms 344 KB Output is correct
43 Correct 9 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 1 ms 348 KB Output is correct
46 Correct 6 ms 448 KB Output is correct
47 Correct 8 ms 344 KB Output is correct
48 Correct 10 ms 348 KB Output is correct
49 Correct 12 ms 344 KB Output is correct
50 Correct 98 ms 444 KB Output is correct
51 Correct 85 ms 344 KB Output is correct
52 Correct 79 ms 448 KB Output is correct
53 Correct 95 ms 440 KB Output is correct
54 Correct 84 ms 344 KB Output is correct
55 Correct 78 ms 344 KB Output is correct
56 Correct 242 ms 348 KB Output is correct
57 Correct 74 ms 344 KB Output is correct
58 Correct 239 ms 348 KB Output is correct
59 Correct 92 ms 440 KB Output is correct
60 Correct 245 ms 348 KB Output is correct
61 Correct 98 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 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 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 600 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 82 ms 444 KB Output is correct
16 Correct 87 ms 348 KB Output is correct
17 Correct 92 ms 348 KB Output is correct
18 Correct 91 ms 348 KB Output is correct
19 Correct 94 ms 348 KB Output is correct
20 Correct 93 ms 348 KB Output is correct
21 Correct 236 ms 344 KB Output is correct
22 Correct 237 ms 448 KB Output is correct
23 Correct 238 ms 348 KB Output is correct
24 Correct 738 ms 1876 KB Output is correct
25 Correct 717 ms 1880 KB Output is correct
26 Correct 719 ms 1792 KB Output is correct
27 Correct 1 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 1 ms 348 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 2 ms 428 KB Output is correct
33 Correct 3 ms 348 KB Output is correct
34 Correct 1 ms 348 KB Output is correct
35 Correct 6 ms 604 KB Output is correct
36 Correct 43 ms 348 KB Output is correct
37 Correct 49 ms 344 KB Output is correct
38 Correct 17 ms 348 KB Output is correct
39 Correct 34 ms 436 KB Output is correct
40 Correct 29 ms 348 KB Output is correct
41 Correct 1 ms 344 KB Output is correct
42 Correct 1 ms 348 KB Output is correct
43 Correct 90 ms 600 KB Output is correct
44 Correct 25 ms 348 KB Output is correct
45 Correct 56 ms 344 KB Output is correct
46 Correct 9 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 1 ms 348 KB Output is correct
49 Correct 6 ms 448 KB Output is correct
50 Correct 8 ms 344 KB Output is correct
51 Correct 10 ms 348 KB Output is correct
52 Correct 12 ms 344 KB Output is correct
53 Correct 98 ms 444 KB Output is correct
54 Correct 85 ms 344 KB Output is correct
55 Correct 79 ms 448 KB Output is correct
56 Correct 95 ms 440 KB Output is correct
57 Correct 84 ms 344 KB Output is correct
58 Correct 78 ms 344 KB Output is correct
59 Correct 242 ms 348 KB Output is correct
60 Correct 74 ms 344 KB Output is correct
61 Correct 239 ms 348 KB Output is correct
62 Correct 92 ms 440 KB Output is correct
63 Correct 245 ms 348 KB Output is correct
64 Correct 98 ms 344 KB Output is correct
65 Correct 0 ms 344 KB Output is correct
66 Correct 1 ms 344 KB Output is correct
67 Correct 1 ms 348 KB Output is correct
68 Correct 1 ms 344 KB Output is correct
69 Correct 1 ms 348 KB Output is correct
70 Correct 74 ms 416 KB Output is correct
71 Correct 39 ms 604 KB Output is correct
72 Correct 5 ms 348 KB Output is correct
73 Correct 1 ms 348 KB Output is correct
74 Correct 8 ms 448 KB Output is correct
75 Correct 52 ms 448 KB Output is correct
76 Correct 157 ms 1880 KB Output is correct
77 Correct 11 ms 1884 KB Output is correct
78 Correct 35 ms 2396 KB Output is correct
79 Correct 1 ms 348 KB Output is correct
80 Correct 1 ms 348 KB Output is correct
81 Correct 1 ms 344 KB Output is correct
82 Correct 1 ms 348 KB Output is correct
83 Correct 1 ms 344 KB Output is correct
84 Correct 61 ms 856 KB Output is correct
85 Correct 94 ms 632 KB Output is correct
86 Correct 74 ms 628 KB Output is correct
87 Correct 76 ms 628 KB Output is correct
88 Correct 55 ms 604 KB Output is correct
89 Correct 71 ms 628 KB Output is correct
90 Correct 809 ms 2560 KB Output is correct
91 Correct 823 ms 2648 KB Output is correct
92 Correct 792 ms 2640 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 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 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 600 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 82 ms 444 KB Output is correct
16 Correct 87 ms 348 KB Output is correct
17 Correct 92 ms 348 KB Output is correct
18 Correct 91 ms 348 KB Output is correct
19 Correct 94 ms 348 KB Output is correct
20 Correct 93 ms 348 KB Output is correct
21 Correct 236 ms 344 KB Output is correct
22 Correct 237 ms 448 KB Output is correct
23 Correct 238 ms 348 KB Output is correct
24 Correct 738 ms 1876 KB Output is correct
25 Correct 717 ms 1880 KB Output is correct
26 Correct 719 ms 1792 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 708 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 4 ms 600 KB Output is correct
32 Correct 5 ms 600 KB Output is correct
33 Execution timed out 1539 ms 1368 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 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 1 ms 348 KB Output is correct
9 Correct 0 ms 344 KB Output is correct
10 Correct 1 ms 348 KB Output is correct
11 Correct 0 ms 600 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 82 ms 444 KB Output is correct
16 Correct 87 ms 348 KB Output is correct
17 Correct 92 ms 348 KB Output is correct
18 Correct 91 ms 348 KB Output is correct
19 Correct 94 ms 348 KB Output is correct
20 Correct 93 ms 348 KB Output is correct
21 Correct 236 ms 344 KB Output is correct
22 Correct 237 ms 448 KB Output is correct
23 Correct 238 ms 348 KB Output is correct
24 Correct 738 ms 1876 KB Output is correct
25 Correct 717 ms 1880 KB Output is correct
26 Correct 719 ms 1792 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 708 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 3 ms 604 KB Output is correct
31 Correct 4 ms 600 KB Output is correct
32 Correct 5 ms 600 KB Output is correct
33 Execution timed out 1539 ms 1368 KB Time limit exceeded
34 Halted 0 ms 0 KB -