Submission #949328

# Submission time Handle Problem Language Result Execution time Memory
949328 2024-03-19T06:25:03 Z vjudge1 Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 10584 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 1880 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 2296 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 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 2 ms 1912 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 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 3 ms 1884 KB Output is correct
22 Correct 22 ms 7260 KB Output is correct
23 Correct 21 ms 7512 KB Output is correct
24 Correct 21 ms 7516 KB Output is correct
25 Correct 5 ms 2140 KB Output is correct
26 Correct 6 ms 2140 KB Output is correct
27 Correct 4 ms 2140 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 1368 ms 3464 KB Output is correct
32 Correct 1370 ms 3464 KB Output is correct
33 Correct 1351 ms 3464 KB Output is correct
34 Correct 1383 ms 3460 KB Output is correct
35 Correct 1346 ms 3420 KB Output is correct
36 Correct 1329 ms 3460 KB Output is correct
37 Execution timed out 1523 ms 7664 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 1880 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 2296 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 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 2 ms 1912 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 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 3 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 1920 KB Output is correct
28 Correct 3 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 3 ms 1884 KB Output is correct
36 Correct 1 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 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 1 ms 1884 KB Output is correct
44 Correct 1 ms 1884 KB Output is correct
45 Correct 4 ms 2040 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 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 1884 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 1884 KB Output is correct
58 Correct 3 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 1880 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 1880 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 2296 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1880 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 2 ms 1912 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 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 3 ms 1884 KB Output is correct
24 Correct 22 ms 7260 KB Output is correct
25 Correct 21 ms 7512 KB Output is correct
26 Correct 21 ms 7516 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 1920 KB Output is correct
31 Correct 3 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 3 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 1880 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 4 ms 2040 KB Output is correct
49 Correct 1 ms 1884 KB Output is correct
50 Correct 1 ms 1880 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 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 1880 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
62 Correct 2 ms 1884 KB Output is correct
63 Correct 2 ms 1884 KB Output is correct
64 Correct 2 ms 1880 KB Output is correct
65 Correct 12 ms 2036 KB Output is correct
66 Correct 6 ms 1880 KB Output is correct
67 Correct 31 ms 1884 KB Output is correct
68 Correct 14 ms 1880 KB Output is correct
69 Correct 28 ms 1880 KB Output is correct
70 Correct 32 ms 2396 KB Output is correct
71 Correct 37 ms 2652 KB Output is correct
72 Correct 19 ms 2396 KB Output is correct
73 Correct 4 ms 2140 KB Output is correct
74 Correct 26 ms 2392 KB Output is correct
75 Correct 20 ms 2392 KB Output is correct
76 Correct 20 ms 8028 KB Output is correct
77 Correct 25 ms 8536 KB Output is correct
78 Correct 25 ms 10152 KB Output is correct
79 Correct 60 ms 2020 KB Output is correct
80 Correct 61 ms 1884 KB Output is correct
81 Correct 61 ms 2036 KB Output is correct
82 Correct 62 ms 2048 KB Output is correct
83 Correct 65 ms 1880 KB Output is correct
84 Correct 62 ms 2908 KB Output is correct
85 Correct 58 ms 2768 KB Output is correct
86 Correct 55 ms 2652 KB Output is correct
87 Correct 52 ms 2652 KB Output is correct
88 Correct 55 ms 2764 KB Output is correct
89 Correct 55 ms 2764 KB Output is correct
90 Correct 33 ms 10328 KB Output is correct
91 Correct 31 ms 10332 KB Output is correct
92 Correct 31 ms 10584 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 1880 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 2296 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1880 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 2 ms 1912 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 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 3 ms 1884 KB Output is correct
24 Correct 22 ms 7260 KB Output is correct
25 Correct 21 ms 7512 KB Output is correct
26 Correct 21 ms 7516 KB Output is correct
27 Correct 5 ms 2140 KB Output is correct
28 Correct 6 ms 2140 KB Output is correct
29 Correct 4 ms 2140 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 1368 ms 3464 KB Output is correct
34 Correct 1370 ms 3464 KB Output is correct
35 Correct 1351 ms 3464 KB Output is correct
36 Correct 1383 ms 3460 KB Output is correct
37 Correct 1346 ms 3420 KB Output is correct
38 Correct 1329 ms 3460 KB Output is correct
39 Execution timed out 1523 ms 7664 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 1880 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 2296 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1880 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 2 ms 1912 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 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 3 ms 1884 KB Output is correct
24 Correct 22 ms 7260 KB Output is correct
25 Correct 21 ms 7512 KB Output is correct
26 Correct 21 ms 7516 KB Output is correct
27 Correct 5 ms 2140 KB Output is correct
28 Correct 6 ms 2140 KB Output is correct
29 Correct 4 ms 2140 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 1368 ms 3464 KB Output is correct
34 Correct 1370 ms 3464 KB Output is correct
35 Correct 1351 ms 3464 KB Output is correct
36 Correct 1383 ms 3460 KB Output is correct
37 Correct 1346 ms 3420 KB Output is correct
38 Correct 1329 ms 3460 KB Output is correct
39 Execution timed out 1523 ms 7664 KB Time limit exceeded
40 Halted 0 ms 0 KB -