Submission #949329

# Submission time Handle Problem Language Result Execution time Memory
949329 2024-03-19T06:26:46 Z vjudge1 Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 10588 KB
#pragma GCC optimize("Ofast,unroll-loops")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>

#include "paint.h"


using namespace std;

const int inf = 1e9, N1 = 1e5 + 10, MX = 1e5 + 1;

int t[N1 * 4];

void update(int pos, int x, int v = 1,int tl = 0, int tr = MX){
    if(tl == tr){
        t[v] = x;
    }else{
        int mid = (tl + tr) >> 1;
        if(pos <= mid)
			update(pos, x, v * 2, tl, mid);
        else
			update(pos, x, v * 2 + 1,mid + 1, tr);
        t[v] = min(t[v * 2], t[v * 2 + 1]);
    }
}
 
int get(int l, int r, int v = 1, int tl = 0, int tr = MX){
    if(tl > r || tr < l)
        return inf;
    if(tl >= l && tr <= r){
        return t[v];
    }
    int mid = (tl + tr) >> 1;
    return min(get(l, r, v * 2, tl, mid),get(l, r, v * 2 + 1, mid + 1, tr));
}


int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
	set <int> st[M];
	for(int i = 0; i < M; i++){
		for(auto x : B[i]){
			st[i].insert(x);
		}
	}
	memset(t, 0x3f3f, sizeof(t));
	for(int i = 0; i + M - 1 < N; i++){
		for(int j = 0; j < M; j++){
			bool flag = 1;
			for(int l = 0; l < M; l++){
				if(st[(l + j) % M].find(C[i + l]) == st[(l + j) % M].end()){
					flag = 0;
					break;
				}
			}
			if(flag){
				if(i == 0)
					update(i + M - 1, 1);

				else{
					int x = get(i - 1, i + M - 2);
					update(i + M - 1, x + 1);
				}
				//cout << i  + M - 1<<"-"<< get(0, 0) << endl;
				break;
			}
		}
	}
	int ans = get(N - 1, N  - 1);
	if(ans == inf)
		return -1;
	return ans;
}


/*
int main() {
  int N, M, K;
  assert(3 == scanf("%d %d %d", &N, &M, &K));
  
  std::vector<int> C(N);
  for (int i = 0; i < N; ++i) {
    assert(1 == scanf("%d", &C[i]));
  }

  std::vector<int> A(M);
  std::vector<std::vector<int>> B(M);
  for (int i = 0; i < M; ++i) {
    assert(1 == scanf("%d", &A[i]));
    B[i].resize(A[i]);
    for (int j = 0; j < A[i]; ++j) {
      assert(1 == scanf("%d", &B[i][j]));
    }
  }

  int minimum_instructions = minimumInstructions(N, M, K, C, A, B);
  printf("%d\n", minimum_instructions);
  
  return 0;
}
*/

# Verdict Execution time Memory Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 1 ms 1884 KB Output is correct
5 Correct 1 ms 1884 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1884 KB Output is correct
8 Correct 1 ms 1884 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1880 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 2 ms 1884 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 2 ms 1880 KB Output is correct
18 Correct 2 ms 1884 KB Output is correct
19 Correct 2 ms 1884 KB Output is correct
20 Correct 2 ms 1884 KB Output is correct
21 Correct 2 ms 1884 KB Output is correct
22 Correct 22 ms 7256 KB Output is correct
23 Correct 24 ms 7260 KB Output is correct
24 Correct 20 ms 7260 KB Output is correct
25 Correct 5 ms 2140 KB Output is correct
26 Correct 5 ms 2140 KB Output is correct
27 Correct 4 ms 2136 KB Output is correct
28 Correct 4 ms 2140 KB Output is correct
29 Correct 3 ms 2140 KB Output is correct
30 Correct 4 ms 2136 KB Output is correct
31 Correct 816 ms 3460 KB Output is correct
32 Correct 801 ms 3664 KB Output is correct
33 Correct 824 ms 3460 KB Output is correct
34 Correct 810 ms 3456 KB Output is correct
35 Correct 801 ms 3420 KB Output is correct
36 Correct 807 ms 3616 KB Output is correct
37 Execution timed out 1535 ms 7768 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Correct 2 ms 1884 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 1 ms 1884 KB Output is correct
5 Correct 1 ms 1884 KB Output is correct
6 Correct 1 ms 1880 KB Output is correct
7 Correct 1 ms 1884 KB Output is correct
8 Correct 1 ms 1884 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1880 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 2 ms 1884 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 2 ms 1880 KB Output is correct
18 Correct 2 ms 1884 KB Output is correct
19 Correct 2 ms 1884 KB Output is correct
20 Correct 2 ms 1884 KB Output is correct
21 Correct 2 ms 1884 KB Output is correct
22 Correct 1 ms 1884 KB Output is correct
23 Correct 1 ms 1884 KB Output is correct
24 Correct 1 ms 1884 KB Output is correct
25 Correct 1 ms 1884 KB Output is correct
26 Correct 1 ms 1884 KB Output is correct
27 Correct 1 ms 1884 KB Output is correct
28 Correct 1 ms 1884 KB Output is correct
29 Correct 1 ms 1884 KB Output is correct
30 Correct 1 ms 1884 KB Output is correct
31 Correct 2 ms 1884 KB Output is correct
32 Correct 1 ms 1884 KB Output is correct
33 Correct 2 ms 1884 KB Output is correct
34 Correct 1 ms 1884 KB Output is correct
35 Correct 1 ms 1880 KB Output is correct
36 Correct 1 ms 1884 KB Output is correct
37 Correct 1 ms 1880 KB Output is correct
38 Correct 1 ms 1884 KB Output is correct
39 Correct 1 ms 1884 KB Output is correct
40 Correct 1 ms 1884 KB Output is correct
41 Correct 1 ms 1884 KB Output is correct
42 Correct 2 ms 1884 KB Output is correct
43 Correct 1 ms 1884 KB Output is correct
44 Correct 1 ms 1880 KB Output is correct
45 Correct 1 ms 1884 KB Output is correct
46 Correct 1 ms 1884 KB Output is correct
47 Correct 1 ms 1884 KB Output is correct
48 Correct 1 ms 1884 KB Output is correct
49 Correct 1 ms 1884 KB Output is correct
50 Correct 2 ms 1884 KB Output is correct
51 Correct 2 ms 1884 KB Output is correct
52 Correct 1 ms 1884 KB Output is correct
53 Correct 2 ms 1880 KB Output is correct
54 Correct 2 ms 1880 KB Output is correct
55 Correct 2 ms 1884 KB Output is correct
56 Correct 2 ms 1884 KB Output is correct
57 Correct 2 ms 1884 KB Output is correct
58 Correct 2 ms 1884 KB Output is correct
59 Correct 3 ms 1880 KB Output is correct
60 Correct 2 ms 1880 KB Output is correct
61 Correct 2 ms 1884 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 1 ms 1884 KB Output is correct
6 Correct 1 ms 1884 KB Output is correct
7 Correct 1 ms 1884 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 1 ms 1880 KB Output is correct
15 Correct 1 ms 1884 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 2 ms 1884 KB Output is correct
18 Correct 2 ms 1884 KB Output is correct
19 Correct 2 ms 1880 KB Output is correct
20 Correct 2 ms 1884 KB Output is correct
21 Correct 2 ms 1884 KB Output is correct
22 Correct 2 ms 1884 KB Output is correct
23 Correct 2 ms 1884 KB Output is correct
24 Correct 22 ms 7256 KB Output is correct
25 Correct 24 ms 7260 KB Output is correct
26 Correct 20 ms 7260 KB Output is correct
27 Correct 1 ms 1884 KB Output is correct
28 Correct 1 ms 1884 KB Output is correct
29 Correct 1 ms 1884 KB Output is correct
30 Correct 1 ms 1884 KB Output is correct
31 Correct 1 ms 1884 KB Output is correct
32 Correct 1 ms 1884 KB Output is correct
33 Correct 1 ms 1884 KB Output is correct
34 Correct 2 ms 1884 KB Output is correct
35 Correct 1 ms 1884 KB Output is correct
36 Correct 2 ms 1884 KB Output is correct
37 Correct 1 ms 1884 KB Output is correct
38 Correct 1 ms 1880 KB Output is correct
39 Correct 1 ms 1884 KB Output is correct
40 Correct 1 ms 1880 KB Output is correct
41 Correct 1 ms 1884 KB Output is correct
42 Correct 1 ms 1884 KB Output is correct
43 Correct 1 ms 1884 KB Output is correct
44 Correct 1 ms 1884 KB Output is correct
45 Correct 2 ms 1884 KB Output is correct
46 Correct 1 ms 1884 KB Output is correct
47 Correct 1 ms 1880 KB Output is correct
48 Correct 1 ms 1884 KB Output is correct
49 Correct 1 ms 1884 KB Output is correct
50 Correct 1 ms 1884 KB Output is correct
51 Correct 1 ms 1884 KB Output is correct
52 Correct 1 ms 1884 KB Output is correct
53 Correct 2 ms 1884 KB Output is correct
54 Correct 2 ms 1884 KB Output is correct
55 Correct 1 ms 1884 KB Output is correct
56 Correct 2 ms 1880 KB Output is correct
57 Correct 2 ms 1880 KB Output is correct
58 Correct 2 ms 1884 KB Output is correct
59 Correct 2 ms 1884 KB Output is correct
60 Correct 2 ms 1884 KB Output is correct
61 Correct 2 ms 1884 KB Output is correct
62 Correct 3 ms 1880 KB Output is correct
63 Correct 2 ms 1880 KB Output is correct
64 Correct 2 ms 1884 KB Output is correct
65 Correct 1 ms 1884 KB Output is correct
66 Correct 2 ms 1884 KB Output is correct
67 Correct 1 ms 1884 KB Output is correct
68 Correct 2 ms 1880 KB Output is correct
69 Correct 1 ms 1884 KB Output is correct
70 Correct 8 ms 2392 KB Output is correct
71 Correct 5 ms 2648 KB Output is correct
72 Correct 5 ms 2396 KB Output is correct
73 Correct 2 ms 2140 KB Output is correct
74 Correct 4 ms 2396 KB Output is correct
75 Correct 5 ms 2396 KB Output is correct
76 Correct 23 ms 8020 KB Output is correct
77 Correct 26 ms 8536 KB Output is correct
78 Correct 25 ms 9836 KB Output is correct
79 Correct 1 ms 1884 KB Output is correct
80 Correct 2 ms 2136 KB Output is correct
81 Correct 2 ms 1884 KB Output is correct
82 Correct 1 ms 1884 KB Output is correct
83 Correct 2 ms 1884 KB Output is correct
84 Correct 5 ms 2652 KB Output is correct
85 Correct 16 ms 2788 KB Output is correct
86 Correct 7 ms 2652 KB Output is correct
87 Correct 6 ms 2652 KB Output is correct
88 Correct 7 ms 2792 KB Output is correct
89 Correct 7 ms 2648 KB Output is correct
90 Correct 29 ms 10324 KB Output is correct
91 Correct 31 ms 10332 KB Output is correct
92 Correct 30 ms 10588 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 1 ms 1884 KB Output is correct
6 Correct 1 ms 1884 KB Output is correct
7 Correct 1 ms 1884 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 1 ms 1880 KB Output is correct
15 Correct 1 ms 1884 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 2 ms 1884 KB Output is correct
18 Correct 2 ms 1884 KB Output is correct
19 Correct 2 ms 1880 KB Output is correct
20 Correct 2 ms 1884 KB Output is correct
21 Correct 2 ms 1884 KB Output is correct
22 Correct 2 ms 1884 KB Output is correct
23 Correct 2 ms 1884 KB Output is correct
24 Correct 22 ms 7256 KB Output is correct
25 Correct 24 ms 7260 KB Output is correct
26 Correct 20 ms 7260 KB Output is correct
27 Correct 5 ms 2140 KB Output is correct
28 Correct 5 ms 2140 KB Output is correct
29 Correct 4 ms 2136 KB Output is correct
30 Correct 4 ms 2140 KB Output is correct
31 Correct 3 ms 2140 KB Output is correct
32 Correct 4 ms 2136 KB Output is correct
33 Correct 816 ms 3460 KB Output is correct
34 Correct 801 ms 3664 KB Output is correct
35 Correct 824 ms 3460 KB Output is correct
36 Correct 810 ms 3456 KB Output is correct
37 Correct 801 ms 3420 KB Output is correct
38 Correct 807 ms 3616 KB Output is correct
39 Execution timed out 1535 ms 7768 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1884 KB Output is correct
2 Correct 1 ms 1884 KB Output is correct
3 Correct 1 ms 1884 KB Output is correct
4 Correct 2 ms 1884 KB Output is correct
5 Correct 1 ms 1884 KB Output is correct
6 Correct 1 ms 1884 KB Output is correct
7 Correct 1 ms 1884 KB Output is correct
8 Correct 1 ms 1880 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 1 ms 1884 KB Output is correct
14 Correct 1 ms 1880 KB Output is correct
15 Correct 1 ms 1884 KB Output is correct
16 Correct 2 ms 1884 KB Output is correct
17 Correct 2 ms 1884 KB Output is correct
18 Correct 2 ms 1884 KB Output is correct
19 Correct 2 ms 1880 KB Output is correct
20 Correct 2 ms 1884 KB Output is correct
21 Correct 2 ms 1884 KB Output is correct
22 Correct 2 ms 1884 KB Output is correct
23 Correct 2 ms 1884 KB Output is correct
24 Correct 22 ms 7256 KB Output is correct
25 Correct 24 ms 7260 KB Output is correct
26 Correct 20 ms 7260 KB Output is correct
27 Correct 5 ms 2140 KB Output is correct
28 Correct 5 ms 2140 KB Output is correct
29 Correct 4 ms 2136 KB Output is correct
30 Correct 4 ms 2140 KB Output is correct
31 Correct 3 ms 2140 KB Output is correct
32 Correct 4 ms 2136 KB Output is correct
33 Correct 816 ms 3460 KB Output is correct
34 Correct 801 ms 3664 KB Output is correct
35 Correct 824 ms 3460 KB Output is correct
36 Correct 810 ms 3456 KB Output is correct
37 Correct 801 ms 3420 KB Output is correct
38 Correct 807 ms 3616 KB Output is correct
39 Execution timed out 1535 ms 7768 KB Time limit exceeded
40 Halted 0 ms 0 KB -