Submission #965828

# Submission time Handle Problem Language Result Execution time Memory
965828 2024-04-19T07:32:39 Z pcc Painting Walls (APIO20_paint) C++17
12 / 100
30 ms 8884 KB
#include "paint.h"

#include <vector>
#include <bits/stdc++.h>
using namespace std;

const int mxn = 1e5+10;
#define pii pair<int,int>
#define fs first
#define sc second
int col[mxn];

int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
	memset(col,-1,sizeof(col));
	for(int i = 0;i<M;i++){
		for(int j = 0;j<A[i];j++)col[B[i][j]] = i;
	}
	vector<pii> v;
	for(int i = 0;i<N;i++)C[i] = col[C[i]];
	for(int i = 0;i<N;i++){
		if(C[i]<0)return -1;
		if(v.empty()||(C[v.back().sc]+1)%M != C[i])v.push_back(pii(i,i));
		else v.back().sc = i;
	}
	int ans = 0;
	for(auto &i:v){
		if(i.sc-i.fs+1<M)return -1;
		ans += (i.sc-i.fs+1+M-1)/M;
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 856 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 1 ms 856 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 856 KB Output is correct
20 Correct 1 ms 856 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 7 ms 2096 KB Output is correct
23 Correct 8 ms 2140 KB Output is correct
24 Correct 7 ms 2100 KB Output is correct
25 Correct 2 ms 860 KB Output is correct
26 Correct 2 ms 820 KB Output is correct
27 Correct 2 ms 1112 KB Output is correct
28 Correct 2 ms 1116 KB Output is correct
29 Correct 2 ms 1116 KB Output is correct
30 Correct 2 ms 1116 KB Output is correct
31 Correct 5 ms 1328 KB Output is correct
32 Correct 4 ms 1372 KB Output is correct
33 Correct 5 ms 1372 KB Output is correct
34 Correct 4 ms 1488 KB Output is correct
35 Correct 4 ms 1408 KB Output is correct
36 Correct 6 ms 1372 KB Output is correct
37 Correct 10 ms 2908 KB Output is correct
38 Correct 9 ms 2908 KB Output is correct
39 Correct 9 ms 2904 KB Output is correct
40 Correct 6 ms 1628 KB Output is correct
41 Correct 4 ms 1368 KB Output is correct
42 Correct 8 ms 2260 KB Output is correct
43 Correct 6 ms 2008 KB Output is correct
44 Correct 5 ms 2008 KB Output is correct
45 Correct 10 ms 2836 KB Output is correct
46 Correct 30 ms 8028 KB Output is correct
47 Correct 13 ms 4444 KB Output is correct
48 Correct 17 ms 7004 KB Output is correct
49 Correct 20 ms 7136 KB Output is correct
50 Correct 23 ms 7380 KB Output is correct
51 Correct 16 ms 5588 KB Output is correct
52 Correct 7 ms 1624 KB Output is correct
53 Correct 7 ms 1624 KB Output is correct
54 Correct 8 ms 2264 KB Output is correct
55 Correct 9 ms 2772 KB Output is correct
56 Correct 11 ms 2772 KB Output is correct
57 Correct 9 ms 2948 KB Output is correct
58 Correct 24 ms 8280 KB Output is correct
59 Correct 24 ms 8284 KB Output is correct
60 Correct 24 ms 8044 KB Output is correct
61 Correct 24 ms 8440 KB Output is correct
62 Correct 30 ms 8272 KB Output is correct
63 Correct 25 ms 8284 KB Output is correct
64 Correct 27 ms 8664 KB Output is correct
65 Correct 26 ms 8880 KB Output is correct
66 Correct 25 ms 8884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 600 KB Output is correct
2 Correct 1 ms 604 KB Output is correct
3 Correct 1 ms 604 KB Output is correct
4 Correct 1 ms 604 KB Output is correct
5 Correct 0 ms 604 KB Output is correct
6 Correct 0 ms 604 KB Output is correct
7 Correct 1 ms 604 KB Output is correct
8 Correct 1 ms 600 KB Output is correct
9 Correct 0 ms 604 KB Output is correct
10 Correct 1 ms 600 KB Output is correct
11 Correct 1 ms 600 KB Output is correct
12 Correct 1 ms 600 KB Output is correct
13 Correct 1 ms 856 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 1 ms 856 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 856 KB Output is correct
20 Correct 1 ms 856 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Incorrect 1 ms 604 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 604 KB Output isn't correct
2 Halted 0 ms 0 KB -