답안 #949342

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
949342 2024-03-19T06:37:20 Z vjudge1 벽 칠하기 (APIO20_paint) C++17
28 / 100
1500 ms 24088 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];
	vector <int> ind[K + 1];
	for(int i = 0; i < M; i++){
		for(auto x : B[i]){
			ind[x].push_back(i);
			mp[i][x] = 1;
		}
	}
	memset(t, 0x3f3f, sizeof(t));
	for(int i = 0; i + M - 1 < N; i++){
		for(auto j : ind[C[i]]){
			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;
}
*/

# 결과 실행 시간 메모리 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 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 1880 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1932 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 4 ms 4440 KB Output is correct
14 Correct 3 ms 4188 KB Output is correct
15 Correct 3 ms 4188 KB Output is correct
16 Correct 4 ms 4184 KB Output is correct
17 Correct 4 ms 4184 KB Output is correct
18 Correct 3 ms 4188 KB Output is correct
19 Correct 4 ms 4440 KB Output is correct
20 Correct 2 ms 4440 KB Output is correct
21 Correct 2 ms 4444 KB Output is correct
22 Correct 25 ms 12124 KB Output is correct
23 Correct 25 ms 12124 KB Output is correct
24 Correct 24 ms 12124 KB Output is correct
25 Correct 5 ms 2140 KB Output is correct
26 Correct 5 ms 2140 KB Output is correct
27 Correct 5 ms 2140 KB Output is correct
28 Correct 3 ms 2140 KB Output is correct
29 Correct 3 ms 2136 KB Output is correct
30 Correct 3 ms 2140 KB Output is correct
31 Correct 755 ms 6372 KB Output is correct
32 Correct 775 ms 6364 KB Output is correct
33 Correct 748 ms 6480 KB Output is correct
34 Correct 741 ms 6368 KB Output is correct
35 Correct 803 ms 6232 KB Output is correct
36 Correct 756 ms 6360 KB Output is correct
37 Correct 37 ms 12624 KB Output is correct
38 Correct 31 ms 12724 KB Output is correct
39 Correct 29 ms 12636 KB Output is correct
40 Correct 21 ms 2732 KB Output is correct
41 Correct 12 ms 2396 KB Output is correct
42 Correct 16 ms 2632 KB Output is correct
43 Correct 8 ms 2396 KB Output is correct
44 Correct 6 ms 2480 KB Output is correct
45 Correct 10 ms 2652 KB Output is correct
46 Execution timed out 1570 ms 24088 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 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 1880 KB Output is correct
10 Correct 1 ms 1884 KB Output is correct
11 Correct 1 ms 1932 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 4 ms 4440 KB Output is correct
14 Correct 3 ms 4188 KB Output is correct
15 Correct 3 ms 4188 KB Output is correct
16 Correct 4 ms 4184 KB Output is correct
17 Correct 4 ms 4184 KB Output is correct
18 Correct 3 ms 4188 KB Output is correct
19 Correct 4 ms 4440 KB Output is correct
20 Correct 2 ms 4440 KB Output is correct
21 Correct 2 ms 4444 KB Output is correct
22 Correct 1 ms 1880 KB Output is correct
23 Correct 1 ms 1880 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 2136 KB Output is correct
31 Correct 2 ms 1880 KB Output is correct
32 Correct 1 ms 1884 KB Output is correct
33 Correct 4 ms 4012 KB Output is correct
34 Correct 3 ms 3420 KB Output is correct
35 Correct 2 ms 3164 KB Output is correct
36 Correct 3 ms 4188 KB Output is correct
37 Correct 2 ms 3896 KB Output is correct
38 Correct 2 ms 3932 KB Output is correct
39 Correct 1 ms 1884 KB Output is correct
40 Correct 2 ms 3676 KB Output is correct
41 Correct 1 ms 1880 KB Output is correct
42 Correct 2 ms 4208 KB Output is correct
43 Correct 3 ms 4188 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 3 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 4 ms 4188 KB Output is correct
51 Correct 3 ms 4444 KB Output is correct
52 Correct 3 ms 4188 KB Output is correct
53 Correct 4 ms 4444 KB Output is correct
54 Correct 4 ms 4188 KB Output is correct
55 Correct 3 ms 4184 KB Output is correct
56 Correct 3 ms 4444 KB Output is correct
57 Correct 2 ms 1884 KB Output is correct
58 Correct 2 ms 4248 KB Output is correct
59 Correct 2 ms 1884 KB Output is correct
60 Correct 3 ms 4440 KB Output is correct
61 Correct 2 ms 1884 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1880 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 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 1880 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 1 ms 1932 KB Output is correct
14 Correct 1 ms 1884 KB Output is correct
15 Correct 4 ms 4440 KB Output is correct
16 Correct 3 ms 4188 KB Output is correct
17 Correct 3 ms 4188 KB Output is correct
18 Correct 4 ms 4184 KB Output is correct
19 Correct 4 ms 4184 KB Output is correct
20 Correct 3 ms 4188 KB Output is correct
21 Correct 4 ms 4440 KB Output is correct
22 Correct 2 ms 4440 KB Output is correct
23 Correct 2 ms 4444 KB Output is correct
24 Correct 25 ms 12124 KB Output is correct
25 Correct 25 ms 12124 KB Output is correct
26 Correct 24 ms 12124 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 2136 KB Output is correct
34 Correct 2 ms 1880 KB Output is correct
35 Correct 1 ms 1884 KB Output is correct
36 Correct 4 ms 4012 KB Output is correct
37 Correct 3 ms 3420 KB Output is correct
38 Correct 2 ms 3164 KB Output is correct
39 Correct 3 ms 4188 KB Output is correct
40 Correct 2 ms 3896 KB Output is correct
41 Correct 2 ms 3932 KB Output is correct
42 Correct 1 ms 1884 KB Output is correct
43 Correct 2 ms 3676 KB Output is correct
44 Correct 1 ms 1880 KB Output is correct
45 Correct 2 ms 4208 KB Output is correct
46 Correct 3 ms 4188 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 3 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 4 ms 4188 KB Output is correct
54 Correct 3 ms 4444 KB Output is correct
55 Correct 3 ms 4188 KB Output is correct
56 Correct 4 ms 4444 KB Output is correct
57 Correct 4 ms 4188 KB Output is correct
58 Correct 3 ms 4184 KB Output is correct
59 Correct 3 ms 4444 KB Output is correct
60 Correct 2 ms 1884 KB Output is correct
61 Correct 2 ms 4248 KB Output is correct
62 Correct 2 ms 1884 KB Output is correct
63 Correct 3 ms 4440 KB Output is correct
64 Correct 2 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 4444 KB Output is correct
71 Correct 7 ms 4188 KB Output is correct
72 Correct 4 ms 3932 KB Output is correct
73 Correct 3 ms 3932 KB Output is correct
74 Correct 5 ms 4444 KB Output is correct
75 Correct 6 ms 4700 KB Output is correct
76 Correct 26 ms 10580 KB Output is correct
77 Correct 26 ms 11848 KB Output is correct
78 Correct 35 ms 13404 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 2 ms 1884 KB Output is correct
84 Correct 8 ms 5212 KB Output is correct
85 Correct 10 ms 5216 KB Output is correct
86 Correct 9 ms 5212 KB Output is correct
87 Correct 8 ms 5212 KB Output is correct
88 Correct 8 ms 5212 KB Output is correct
89 Correct 8 ms 4952 KB Output is correct
90 Correct 46 ms 14576 KB Output is correct
91 Correct 52 ms 14748 KB Output is correct
92 Correct 40 ms 14672 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1880 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 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 1880 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 1 ms 1932 KB Output is correct
14 Correct 1 ms 1884 KB Output is correct
15 Correct 4 ms 4440 KB Output is correct
16 Correct 3 ms 4188 KB Output is correct
17 Correct 3 ms 4188 KB Output is correct
18 Correct 4 ms 4184 KB Output is correct
19 Correct 4 ms 4184 KB Output is correct
20 Correct 3 ms 4188 KB Output is correct
21 Correct 4 ms 4440 KB Output is correct
22 Correct 2 ms 4440 KB Output is correct
23 Correct 2 ms 4444 KB Output is correct
24 Correct 25 ms 12124 KB Output is correct
25 Correct 25 ms 12124 KB Output is correct
26 Correct 24 ms 12124 KB Output is correct
27 Correct 5 ms 2140 KB Output is correct
28 Correct 5 ms 2140 KB Output is correct
29 Correct 5 ms 2140 KB Output is correct
30 Correct 3 ms 2140 KB Output is correct
31 Correct 3 ms 2136 KB Output is correct
32 Correct 3 ms 2140 KB Output is correct
33 Correct 755 ms 6372 KB Output is correct
34 Correct 775 ms 6364 KB Output is correct
35 Correct 748 ms 6480 KB Output is correct
36 Correct 741 ms 6368 KB Output is correct
37 Correct 803 ms 6232 KB Output is correct
38 Correct 756 ms 6360 KB Output is correct
39 Correct 37 ms 12624 KB Output is correct
40 Correct 31 ms 12724 KB Output is correct
41 Correct 29 ms 12636 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 2136 KB Output is correct
49 Correct 2 ms 1880 KB Output is correct
50 Correct 1 ms 1884 KB Output is correct
51 Correct 4 ms 4012 KB Output is correct
52 Correct 3 ms 3420 KB Output is correct
53 Correct 2 ms 3164 KB Output is correct
54 Correct 3 ms 4188 KB Output is correct
55 Correct 2 ms 3896 KB Output is correct
56 Correct 2 ms 3932 KB Output is correct
57 Correct 1 ms 1884 KB Output is correct
58 Correct 2 ms 3676 KB Output is correct
59 Correct 1 ms 1880 KB Output is correct
60 Correct 2 ms 4208 KB Output is correct
61 Correct 3 ms 4188 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 1884 KB Output is correct
65 Correct 3 ms 1884 KB Output is correct
66 Correct 1 ms 1884 KB Output is correct
67 Correct 1 ms 1884 KB Output is correct
68 Correct 4 ms 4188 KB Output is correct
69 Correct 3 ms 4444 KB Output is correct
70 Correct 3 ms 4188 KB Output is correct
71 Correct 4 ms 4444 KB Output is correct
72 Correct 4 ms 4188 KB Output is correct
73 Correct 3 ms 4184 KB Output is correct
74 Correct 3 ms 4444 KB Output is correct
75 Correct 2 ms 1884 KB Output is correct
76 Correct 2 ms 4248 KB Output is correct
77 Correct 2 ms 1884 KB Output is correct
78 Correct 3 ms 4440 KB Output is correct
79 Correct 2 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 4444 KB Output is correct
86 Correct 7 ms 4188 KB Output is correct
87 Correct 4 ms 3932 KB Output is correct
88 Correct 3 ms 3932 KB Output is correct
89 Correct 5 ms 4444 KB Output is correct
90 Correct 6 ms 4700 KB Output is correct
91 Correct 26 ms 10580 KB Output is correct
92 Correct 26 ms 11848 KB Output is correct
93 Correct 35 ms 13404 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 2 ms 1884 KB Output is correct
99 Correct 8 ms 5212 KB Output is correct
100 Correct 10 ms 5216 KB Output is correct
101 Correct 9 ms 5212 KB Output is correct
102 Correct 8 ms 5212 KB Output is correct
103 Correct 8 ms 5212 KB Output is correct
104 Correct 8 ms 4952 KB Output is correct
105 Correct 46 ms 14576 KB Output is correct
106 Correct 52 ms 14748 KB Output is correct
107 Correct 40 ms 14672 KB Output is correct
108 Correct 7 ms 2140 KB Output is correct
109 Correct 80 ms 2292 KB Output is correct
110 Correct 213 ms 2284 KB Output is correct
111 Correct 139 ms 2140 KB Output is correct
112 Correct 152 ms 2348 KB Output is correct
113 Correct 76 ms 2396 KB Output is correct
114 Correct 521 ms 7668 KB Output is correct
115 Correct 45 ms 7512 KB Output is correct
116 Correct 398 ms 8792 KB Output is correct
117 Correct 308 ms 7000 KB Output is correct
118 Correct 57 ms 8024 KB Output is correct
119 Correct 703 ms 7172 KB Output is correct
120 Correct 25 ms 9820 KB Output is correct
121 Correct 328 ms 3508 KB Output is correct
122 Correct 29 ms 10588 KB Output is correct
123 Correct 114 ms 3244 KB Output is correct
124 Correct 34 ms 12272 KB Output is correct
125 Correct 68 ms 3840 KB Output is correct
126 Correct 14 ms 4956 KB Output is correct
127 Correct 153 ms 6056 KB Output is correct
128 Correct 32 ms 5212 KB Output is correct
129 Correct 47 ms 4696 KB Output is correct
130 Correct 5 ms 2140 KB Output is correct
131 Correct 111 ms 2340 KB Output is correct
132 Correct 347 ms 2396 KB Output is correct
133 Correct 247 ms 2392 KB Output is correct
134 Correct 192 ms 2644 KB Output is correct
135 Correct 162 ms 2496 KB Output is correct
136 Correct 1467 ms 9468 KB Output is correct
137 Correct 1227 ms 9452 KB Output is correct
138 Execution timed out 1525 ms 9560 KB Time limit exceeded
139 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1880 KB Output is correct
2 Correct 1 ms 1880 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 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 1880 KB Output is correct
12 Correct 1 ms 1884 KB Output is correct
13 Correct 1 ms 1932 KB Output is correct
14 Correct 1 ms 1884 KB Output is correct
15 Correct 4 ms 4440 KB Output is correct
16 Correct 3 ms 4188 KB Output is correct
17 Correct 3 ms 4188 KB Output is correct
18 Correct 4 ms 4184 KB Output is correct
19 Correct 4 ms 4184 KB Output is correct
20 Correct 3 ms 4188 KB Output is correct
21 Correct 4 ms 4440 KB Output is correct
22 Correct 2 ms 4440 KB Output is correct
23 Correct 2 ms 4444 KB Output is correct
24 Correct 25 ms 12124 KB Output is correct
25 Correct 25 ms 12124 KB Output is correct
26 Correct 24 ms 12124 KB Output is correct
27 Correct 5 ms 2140 KB Output is correct
28 Correct 5 ms 2140 KB Output is correct
29 Correct 5 ms 2140 KB Output is correct
30 Correct 3 ms 2140 KB Output is correct
31 Correct 3 ms 2136 KB Output is correct
32 Correct 3 ms 2140 KB Output is correct
33 Correct 755 ms 6372 KB Output is correct
34 Correct 775 ms 6364 KB Output is correct
35 Correct 748 ms 6480 KB Output is correct
36 Correct 741 ms 6368 KB Output is correct
37 Correct 803 ms 6232 KB Output is correct
38 Correct 756 ms 6360 KB Output is correct
39 Correct 37 ms 12624 KB Output is correct
40 Correct 31 ms 12724 KB Output is correct
41 Correct 29 ms 12636 KB Output is correct
42 Correct 21 ms 2732 KB Output is correct
43 Correct 12 ms 2396 KB Output is correct
44 Correct 16 ms 2632 KB Output is correct
45 Correct 8 ms 2396 KB Output is correct
46 Correct 6 ms 2480 KB Output is correct
47 Correct 10 ms 2652 KB Output is correct
48 Execution timed out 1570 ms 24088 KB Time limit exceeded
49 Halted 0 ms 0 KB -