Submission #949336

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

#include "paint.h"
#define rnd(l, r) uniform_int_distribution<int>(l, r)(rng)

using namespace std;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 

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++){
		int st = rnd(0, M - 1);
		for(int j = 0; j < M; j++){
			bool flag = 1;
			for(int l = 0; l < M; l++){
				if( !mp[(st + 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 1872 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 1 ms 1880 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 2 ms 2292 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 1880 KB Output is correct
19 Correct 3 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 17 ms 6716 KB Output is correct
23 Correct 20 ms 6748 KB Output is correct
24 Correct 18 ms 6748 KB Output is correct
25 Correct 5 ms 2140 KB Output is correct
26 Correct 8 ms 2136 KB Output is correct
27 Correct 7 ms 2140 KB Output is correct
28 Correct 4 ms 2140 KB Output is correct
29 Correct 4 ms 2140 KB Output is correct
30 Correct 4 ms 2140 KB Output is correct
31 Correct 1136 ms 3400 KB Output is correct
32 Correct 1120 ms 3388 KB Output is correct
33 Correct 1131 ms 3380 KB Output is correct
34 Correct 1125 ms 3388 KB Output is correct
35 Correct 1124 ms 3388 KB Output is correct
36 Correct 1111 ms 3404 KB Output is correct
37 Correct 1159 ms 7360 KB Output is correct
38 Correct 1181 ms 7360 KB Output is correct
39 Correct 1137 ms 7364 KB Output is correct
40 Correct 21 ms 2652 KB Output is correct
41 Correct 13 ms 2396 KB Output is correct
42 Correct 20 ms 2652 KB Output is correct
43 Correct 10 ms 2396 KB Output is correct
44 Correct 9 ms 2396 KB Output is correct
45 Correct 15 ms 2652 KB Output is correct
46 Execution timed out 1594 ms 18856 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1872 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 1 ms 1880 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 2 ms 2292 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 1880 KB Output is correct
19 Correct 3 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 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 2 ms 1884 KB Output is correct
29 Correct 2 ms 1880 KB Output is correct
30 Correct 2 ms 1880 KB Output is correct
31 Correct 1 ms 1880 KB Output is correct
32 Correct 2 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 2 ms 1884 KB Output is correct
36 Correct 2 ms 1880 KB Output is correct
37 Correct 3 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 1880 KB Output is correct
42 Correct 2 ms 1884 KB Output is correct
43 Correct 2 ms 1880 KB Output is correct
44 Correct 1 ms 1884 KB Output is correct
45 Correct 1 ms 1884 KB Output is correct
46 Correct 2 ms 1880 KB Output is correct
47 Correct 1 ms 1884 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 1884 KB Output is correct
51 Correct 2 ms 2072 KB Output is correct
52 Correct 2 ms 1880 KB Output is correct
53 Correct 2 ms 1884 KB Output is correct
54 Correct 2 ms 2080 KB Output is correct
55 Correct 2 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 1880 KB Output is correct
59 Correct 2 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 1872 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 1 ms 1884 KB Output is correct
8 Correct 1 ms 1884 KB Output is correct
9 Correct 1 ms 1880 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 2 ms 2292 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 1880 KB Output is correct
21 Correct 3 ms 1880 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 6716 KB Output is correct
25 Correct 20 ms 6748 KB Output is correct
26 Correct 18 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 2 ms 1884 KB Output is correct
32 Correct 2 ms 1880 KB Output is correct
33 Correct 2 ms 1880 KB Output is correct
34 Correct 1 ms 1880 KB Output is correct
35 Correct 2 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 2 ms 1884 KB Output is correct
39 Correct 2 ms 1880 KB Output is correct
40 Correct 3 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 1880 KB Output is correct
45 Correct 2 ms 1884 KB Output is correct
46 Correct 2 ms 1880 KB Output is correct
47 Correct 1 ms 1884 KB Output is correct
48 Correct 1 ms 1884 KB Output is correct
49 Correct 2 ms 1880 KB Output is correct
50 Correct 1 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 3 ms 1884 KB Output is correct
54 Correct 2 ms 2072 KB Output is correct
55 Correct 2 ms 1880 KB Output is correct
56 Correct 2 ms 1884 KB Output is correct
57 Correct 2 ms 2080 KB Output is correct
58 Correct 2 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 1880 KB Output is correct
62 Correct 2 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 1880 KB Output is correct
66 Correct 1 ms 1884 KB Output is correct
67 Correct 2 ms 1884 KB Output is correct
68 Correct 2 ms 1884 KB Output is correct
69 Correct 2 ms 1884 KB Output is correct
70 Correct 7 ms 2396 KB Output is correct
71 Correct 6 ms 2396 KB Output is correct
72 Correct 4 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 7 ms 2396 KB Output is correct
76 Correct 27 ms 7328 KB Output is correct
77 Correct 19 ms 7608 KB Output is correct
78 Correct 26 ms 8948 KB Output is correct
79 Correct 2 ms 1884 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 3 ms 1884 KB Output is correct
84 Correct 9 ms 2776 KB Output is correct
85 Correct 8 ms 2652 KB Output is correct
86 Correct 11 ms 2652 KB Output is correct
87 Correct 8 ms 2652 KB Output is correct
88 Correct 9 ms 2652 KB Output is correct
89 Correct 7 ms 2652 KB Output is correct
90 Correct 30 ms 9820 KB Output is correct
91 Correct 26 ms 9876 KB Output is correct
92 Correct 29 ms 9816 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 1872 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 1 ms 1884 KB Output is correct
8 Correct 1 ms 1884 KB Output is correct
9 Correct 1 ms 1880 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 2 ms 2292 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 1880 KB Output is correct
21 Correct 3 ms 1880 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 6716 KB Output is correct
25 Correct 20 ms 6748 KB Output is correct
26 Correct 18 ms 6748 KB Output is correct
27 Correct 5 ms 2140 KB Output is correct
28 Correct 8 ms 2136 KB Output is correct
29 Correct 7 ms 2140 KB Output is correct
30 Correct 4 ms 2140 KB Output is correct
31 Correct 4 ms 2140 KB Output is correct
32 Correct 4 ms 2140 KB Output is correct
33 Correct 1136 ms 3400 KB Output is correct
34 Correct 1120 ms 3388 KB Output is correct
35 Correct 1131 ms 3380 KB Output is correct
36 Correct 1125 ms 3388 KB Output is correct
37 Correct 1124 ms 3388 KB Output is correct
38 Correct 1111 ms 3404 KB Output is correct
39 Correct 1159 ms 7360 KB Output is correct
40 Correct 1181 ms 7360 KB Output is correct
41 Correct 1137 ms 7364 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 2 ms 1884 KB Output is correct
47 Correct 2 ms 1880 KB Output is correct
48 Correct 2 ms 1880 KB Output is correct
49 Correct 1 ms 1880 KB Output is correct
50 Correct 2 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 2 ms 1884 KB Output is correct
54 Correct 2 ms 1880 KB Output is correct
55 Correct 3 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 1880 KB Output is correct
60 Correct 2 ms 1884 KB Output is correct
61 Correct 2 ms 1880 KB Output is correct
62 Correct 1 ms 1884 KB Output is correct
63 Correct 1 ms 1884 KB Output is correct
64 Correct 2 ms 1880 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 3 ms 1884 KB Output is correct
69 Correct 2 ms 2072 KB Output is correct
70 Correct 2 ms 1880 KB Output is correct
71 Correct 2 ms 1884 KB Output is correct
72 Correct 2 ms 2080 KB Output is correct
73 Correct 2 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 1880 KB Output is correct
77 Correct 2 ms 1880 KB Output is correct
78 Correct 2 ms 1880 KB Output is correct
79 Correct 2 ms 1884 KB Output is correct
80 Correct 1 ms 1880 KB Output is correct
81 Correct 1 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 2 ms 1884 KB Output is correct
85 Correct 7 ms 2396 KB Output is correct
86 Correct 6 ms 2396 KB Output is correct
87 Correct 4 ms 2396 KB Output is correct
88 Correct 2 ms 2140 KB Output is correct
89 Correct 4 ms 2396 KB Output is correct
90 Correct 7 ms 2396 KB Output is correct
91 Correct 27 ms 7328 KB Output is correct
92 Correct 19 ms 7608 KB Output is correct
93 Correct 26 ms 8948 KB Output is correct
94 Correct 2 ms 1884 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 3 ms 1884 KB Output is correct
99 Correct 9 ms 2776 KB Output is correct
100 Correct 8 ms 2652 KB Output is correct
101 Correct 11 ms 2652 KB Output is correct
102 Correct 8 ms 2652 KB Output is correct
103 Correct 9 ms 2652 KB Output is correct
104 Correct 7 ms 2652 KB Output is correct
105 Correct 30 ms 9820 KB Output is correct
106 Correct 26 ms 9876 KB Output is correct
107 Correct 29 ms 9816 KB Output is correct
108 Correct 6 ms 2140 KB Output is correct
109 Correct 80 ms 2292 KB Output is correct
110 Correct 248 ms 2140 KB Output is correct
111 Correct 200 ms 2284 KB Output is correct
112 Correct 230 ms 2336 KB Output is correct
113 Correct 154 ms 2368 KB Output is correct
114 Correct 620 ms 4844 KB Output is correct
115 Correct 57 ms 4956 KB Output is correct
116 Correct 610 ms 5724 KB Output is correct
117 Correct 382 ms 4960 KB Output is correct
118 Correct 68 ms 5208 KB Output is correct
119 Correct 868 ms 4488 KB Output is correct
120 Correct 596 ms 6800 KB Output is correct
121 Correct 483 ms 2996 KB Output is correct
122 Correct 204 ms 7772 KB Output is correct
123 Correct 172 ms 2648 KB Output is correct
124 Correct 107 ms 8536 KB Output is correct
125 Correct 100 ms 2908 KB Output is correct
126 Correct 16 ms 3160 KB Output is correct
127 Correct 413 ms 3568 KB Output is correct
128 Correct 67 ms 3412 KB Output is correct
129 Correct 114 ms 3164 KB Output is correct
130 Correct 7 ms 2136 KB Output is correct
131 Correct 111 ms 2332 KB Output is correct
132 Correct 428 ms 2396 KB Output is correct
133 Correct 376 ms 2396 KB Output is correct
134 Correct 346 ms 2640 KB Output is correct
135 Correct 331 ms 2476 KB Output is correct
136 Execution timed out 1595 ms 6352 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 1872 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 1 ms 1884 KB Output is correct
8 Correct 1 ms 1884 KB Output is correct
9 Correct 1 ms 1880 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 2 ms 2292 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 1880 KB Output is correct
21 Correct 3 ms 1880 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 6716 KB Output is correct
25 Correct 20 ms 6748 KB Output is correct
26 Correct 18 ms 6748 KB Output is correct
27 Correct 5 ms 2140 KB Output is correct
28 Correct 8 ms 2136 KB Output is correct
29 Correct 7 ms 2140 KB Output is correct
30 Correct 4 ms 2140 KB Output is correct
31 Correct 4 ms 2140 KB Output is correct
32 Correct 4 ms 2140 KB Output is correct
33 Correct 1136 ms 3400 KB Output is correct
34 Correct 1120 ms 3388 KB Output is correct
35 Correct 1131 ms 3380 KB Output is correct
36 Correct 1125 ms 3388 KB Output is correct
37 Correct 1124 ms 3388 KB Output is correct
38 Correct 1111 ms 3404 KB Output is correct
39 Correct 1159 ms 7360 KB Output is correct
40 Correct 1181 ms 7360 KB Output is correct
41 Correct 1137 ms 7364 KB Output is correct
42 Correct 21 ms 2652 KB Output is correct
43 Correct 13 ms 2396 KB Output is correct
44 Correct 20 ms 2652 KB Output is correct
45 Correct 10 ms 2396 KB Output is correct
46 Correct 9 ms 2396 KB Output is correct
47 Correct 15 ms 2652 KB Output is correct
48 Execution timed out 1594 ms 18856 KB Time limit exceeded
49 Halted 0 ms 0 KB -