Submission #949332

# Submission time Handle Problem Language Result Execution time Memory
949332 2024-03-19T06:29:33 Z vjudge1 Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 19012 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) {
	unordered_map <int,int> mp[M];
	for(int i = 0; i < M; i++){
		for(auto x : B[i]){
			mp[i][x] = 1;
		}
	}
	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( !mp[(l + j) % M].count(C[i + l])){
					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 1 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 2 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 1884 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 2 ms 1884 KB Output is correct
14 Correct 3 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 3 ms 1884 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 17 ms 6748 KB Output is correct
23 Correct 18 ms 6744 KB Output is correct
24 Correct 23 ms 6748 KB Output is correct
25 Correct 5 ms 2136 KB Output is correct
26 Correct 5 ms 2140 KB Output is correct
27 Correct 4 ms 2160 KB Output is correct
28 Correct 3 ms 2140 KB Output is correct
29 Correct 3 ms 2140 KB Output is correct
30 Correct 3 ms 2140 KB Output is correct
31 Correct 1121 ms 3384 KB Output is correct
32 Correct 1104 ms 3380 KB Output is correct
33 Correct 1099 ms 3160 KB Output is correct
34 Correct 1122 ms 3384 KB Output is correct
35 Correct 1089 ms 3380 KB Output is correct
36 Correct 1094 ms 3380 KB Output is correct
37 Correct 1137 ms 7352 KB Output is correct
38 Correct 1126 ms 7348 KB Output is correct
39 Correct 1133 ms 7356 KB Output is correct
40 Correct 19 ms 2652 KB Output is correct
41 Correct 12 ms 2392 KB Output is correct
42 Correct 17 ms 2652 KB Output is correct
43 Correct 9 ms 2524 KB Output is correct
44 Correct 8 ms 2480 KB Output is correct
45 Correct 13 ms 2652 KB Output is correct
46 Execution timed out 1567 ms 19012 KB Time limit exceeded
47 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 1 ms 1884 KB Output is correct
5 Correct 2 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 1884 KB Output is correct
9 Correct 1 ms 1884 KB Output is correct
10 Correct 1 ms 1880 KB Output is correct
11 Correct 1 ms 1884 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 2 ms 1884 KB Output is correct
14 Correct 3 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 3 ms 1884 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 1 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 2 ms 1884 KB Output is correct
35 Correct 1 ms 1884 KB Output is correct
36 Correct 3 ms 1884 KB Output is correct
37 Correct 2 ms 1884 KB Output is correct
38 Correct 1 ms 1884 KB Output is correct
39 Correct 1 ms 1884 KB Output is correct
40 Correct 2 ms 1884 KB Output is correct
41 Correct 2 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 1 ms 1884 KB Output is correct
46 Correct 1 ms 1880 KB Output is correct
47 Correct 1 ms 1880 KB Output is correct
48 Correct 2 ms 1884 KB Output is correct
49 Correct 1 ms 1884 KB Output is correct
50 Correct 3 ms 1880 KB Output is correct
51 Correct 3 ms 1880 KB Output is correct
52 Correct 3 ms 1880 KB Output is correct
53 Correct 2 ms 1884 KB Output is correct
54 Correct 2 ms 1884 KB Output is correct
55 Correct 3 ms 1884 KB Output is correct
56 Correct 2 ms 1880 KB Output is correct
57 Correct 2 ms 1884 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 3 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 1 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 2 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 1 ms 1884 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 3 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 3 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 2 ms 1884 KB Output is correct
23 Correct 2 ms 1884 KB Output is correct
24 Correct 17 ms 6748 KB Output is correct
25 Correct 18 ms 6744 KB Output is correct
26 Correct 23 ms 6748 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 1 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 2 ms 1884 KB Output is correct
38 Correct 1 ms 1884 KB Output is correct
39 Correct 3 ms 1884 KB Output is correct
40 Correct 2 ms 1884 KB Output is correct
41 Correct 1 ms 1884 KB Output is correct
42 Correct 1 ms 1884 KB Output is correct
43 Correct 2 ms 1884 KB Output is correct
44 Correct 2 ms 1884 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 1880 KB Output is correct
50 Correct 1 ms 1880 KB Output is correct
51 Correct 2 ms 1884 KB Output is correct
52 Correct 1 ms 1884 KB Output is correct
53 Correct 3 ms 1880 KB Output is correct
54 Correct 3 ms 1880 KB Output is correct
55 Correct 3 ms 1880 KB Output is correct
56 Correct 2 ms 1884 KB Output is correct
57 Correct 2 ms 1884 KB Output is correct
58 Correct 3 ms 1884 KB Output is correct
59 Correct 2 ms 1880 KB Output is correct
60 Correct 2 ms 1884 KB Output is correct
61 Correct 2 ms 1884 KB Output is correct
62 Correct 2 ms 1884 KB Output is correct
63 Correct 2 ms 1884 KB Output is correct
64 Correct 3 ms 1884 KB Output is correct
65 Correct 1 ms 1884 KB Output is correct
66 Correct 1 ms 1884 KB Output is correct
67 Correct 2 ms 1884 KB Output is correct
68 Correct 1 ms 1884 KB Output is correct
69 Correct 2 ms 1884 KB Output is correct
70 Correct 8 ms 2392 KB Output is correct
71 Correct 6 ms 2396 KB Output is correct
72 Correct 4 ms 2392 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 19 ms 7208 KB Output is correct
77 Correct 19 ms 7608 KB Output is correct
78 Correct 26 ms 8796 KB Output is correct
79 Correct 2 ms 2136 KB Output is correct
80 Correct 2 ms 1884 KB Output is correct
81 Correct 2 ms 1884 KB Output is correct
82 Correct 2 ms 1884 KB Output is correct
83 Correct 2 ms 1884 KB Output is correct
84 Correct 6 ms 2652 KB Output is correct
85 Correct 9 ms 2652 KB Output is correct
86 Correct 8 ms 2772 KB Output is correct
87 Correct 7 ms 2652 KB Output is correct
88 Correct 8 ms 2652 KB Output is correct
89 Correct 7 ms 2652 KB Output is correct
90 Correct 27 ms 9832 KB Output is correct
91 Correct 28 ms 9820 KB Output is correct
92 Correct 33 ms 9840 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 1 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 2 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 1 ms 1884 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 3 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 3 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 2 ms 1884 KB Output is correct
23 Correct 2 ms 1884 KB Output is correct
24 Correct 17 ms 6748 KB Output is correct
25 Correct 18 ms 6744 KB Output is correct
26 Correct 23 ms 6748 KB Output is correct
27 Correct 5 ms 2136 KB Output is correct
28 Correct 5 ms 2140 KB Output is correct
29 Correct 4 ms 2160 KB Output is correct
30 Correct 3 ms 2140 KB Output is correct
31 Correct 3 ms 2140 KB Output is correct
32 Correct 3 ms 2140 KB Output is correct
33 Correct 1121 ms 3384 KB Output is correct
34 Correct 1104 ms 3380 KB Output is correct
35 Correct 1099 ms 3160 KB Output is correct
36 Correct 1122 ms 3384 KB Output is correct
37 Correct 1089 ms 3380 KB Output is correct
38 Correct 1094 ms 3380 KB Output is correct
39 Correct 1137 ms 7352 KB Output is correct
40 Correct 1126 ms 7348 KB Output is correct
41 Correct 1133 ms 7356 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 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 1 ms 1884 KB Output is correct
51 Correct 2 ms 1884 KB Output is correct
52 Correct 2 ms 1884 KB Output is correct
53 Correct 1 ms 1884 KB Output is correct
54 Correct 3 ms 1884 KB Output is correct
55 Correct 2 ms 1884 KB Output is correct
56 Correct 1 ms 1884 KB Output is correct
57 Correct 1 ms 1884 KB Output is correct
58 Correct 2 ms 1884 KB Output is correct
59 Correct 2 ms 1884 KB Output is correct
60 Correct 1 ms 1884 KB Output is correct
61 Correct 1 ms 1884 KB Output is correct
62 Correct 1 ms 1884 KB Output is correct
63 Correct 1 ms 1884 KB Output is correct
64 Correct 1 ms 1880 KB Output is correct
65 Correct 1 ms 1880 KB Output is correct
66 Correct 2 ms 1884 KB Output is correct
67 Correct 1 ms 1884 KB Output is correct
68 Correct 3 ms 1880 KB Output is correct
69 Correct 3 ms 1880 KB Output is correct
70 Correct 3 ms 1880 KB Output is correct
71 Correct 2 ms 1884 KB Output is correct
72 Correct 2 ms 1884 KB Output is correct
73 Correct 3 ms 1884 KB Output is correct
74 Correct 2 ms 1880 KB Output is correct
75 Correct 2 ms 1884 KB Output is correct
76 Correct 2 ms 1884 KB Output is correct
77 Correct 2 ms 1884 KB Output is correct
78 Correct 2 ms 1884 KB Output is correct
79 Correct 3 ms 1884 KB Output is correct
80 Correct 1 ms 1884 KB Output is correct
81 Correct 1 ms 1884 KB Output is correct
82 Correct 2 ms 1884 KB Output is correct
83 Correct 1 ms 1884 KB Output is correct
84 Correct 2 ms 1884 KB Output is correct
85 Correct 8 ms 2392 KB Output is correct
86 Correct 6 ms 2396 KB Output is correct
87 Correct 4 ms 2392 KB Output is correct
88 Correct 2 ms 2140 KB Output is correct
89 Correct 4 ms 2396 KB Output is correct
90 Correct 5 ms 2396 KB Output is correct
91 Correct 19 ms 7208 KB Output is correct
92 Correct 19 ms 7608 KB Output is correct
93 Correct 26 ms 8796 KB Output is correct
94 Correct 2 ms 2136 KB Output is correct
95 Correct 2 ms 1884 KB Output is correct
96 Correct 2 ms 1884 KB Output is correct
97 Correct 2 ms 1884 KB Output is correct
98 Correct 2 ms 1884 KB Output is correct
99 Correct 6 ms 2652 KB Output is correct
100 Correct 9 ms 2652 KB Output is correct
101 Correct 8 ms 2772 KB Output is correct
102 Correct 7 ms 2652 KB Output is correct
103 Correct 8 ms 2652 KB Output is correct
104 Correct 7 ms 2652 KB Output is correct
105 Correct 27 ms 9832 KB Output is correct
106 Correct 28 ms 9820 KB Output is correct
107 Correct 33 ms 9840 KB Output is correct
108 Correct 5 ms 2140 KB Output is correct
109 Correct 80 ms 2276 KB Output is correct
110 Correct 251 ms 2292 KB Output is correct
111 Correct 196 ms 2140 KB Output is correct
112 Correct 235 ms 2336 KB Output is correct
113 Correct 152 ms 2388 KB Output is correct
114 Correct 709 ms 4944 KB Output is correct
115 Correct 50 ms 4956 KB Output is correct
116 Correct 553 ms 5724 KB Output is correct
117 Correct 432 ms 4988 KB Output is correct
118 Correct 65 ms 5212 KB Output is correct
119 Correct 927 ms 4488 KB Output is correct
120 Correct 591 ms 6796 KB Output is correct
121 Correct 476 ms 2904 KB Output is correct
122 Correct 208 ms 8016 KB Output is correct
123 Correct 166 ms 2652 KB Output is correct
124 Correct 107 ms 8280 KB Output is correct
125 Correct 97 ms 3028 KB Output is correct
126 Correct 16 ms 3160 KB Output is correct
127 Correct 414 ms 3420 KB Output is correct
128 Correct 69 ms 3416 KB Output is correct
129 Correct 114 ms 3164 KB Output is correct
130 Correct 5 ms 2136 KB Output is correct
131 Correct 111 ms 2140 KB Output is correct
132 Correct 429 ms 2648 KB Output is correct
133 Correct 378 ms 2416 KB Output is correct
134 Correct 342 ms 2448 KB Output is correct
135 Correct 325 ms 2396 KB Output is correct
136 Execution timed out 1538 ms 6492 KB Time limit exceeded
137 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 1 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 2 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 1 ms 1884 KB Output is correct
15 Correct 2 ms 1884 KB Output is correct
16 Correct 3 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 3 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 2 ms 1884 KB Output is correct
23 Correct 2 ms 1884 KB Output is correct
24 Correct 17 ms 6748 KB Output is correct
25 Correct 18 ms 6744 KB Output is correct
26 Correct 23 ms 6748 KB Output is correct
27 Correct 5 ms 2136 KB Output is correct
28 Correct 5 ms 2140 KB Output is correct
29 Correct 4 ms 2160 KB Output is correct
30 Correct 3 ms 2140 KB Output is correct
31 Correct 3 ms 2140 KB Output is correct
32 Correct 3 ms 2140 KB Output is correct
33 Correct 1121 ms 3384 KB Output is correct
34 Correct 1104 ms 3380 KB Output is correct
35 Correct 1099 ms 3160 KB Output is correct
36 Correct 1122 ms 3384 KB Output is correct
37 Correct 1089 ms 3380 KB Output is correct
38 Correct 1094 ms 3380 KB Output is correct
39 Correct 1137 ms 7352 KB Output is correct
40 Correct 1126 ms 7348 KB Output is correct
41 Correct 1133 ms 7356 KB Output is correct
42 Correct 19 ms 2652 KB Output is correct
43 Correct 12 ms 2392 KB Output is correct
44 Correct 17 ms 2652 KB Output is correct
45 Correct 9 ms 2524 KB Output is correct
46 Correct 8 ms 2480 KB Output is correct
47 Correct 13 ms 2652 KB Output is correct
48 Execution timed out 1567 ms 19012 KB Time limit exceeded
49 Halted 0 ms 0 KB -