답안 #741432

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
741432 2023-05-14T05:11:30 Z penguin133 벽 칠하기 (APIO20_paint) C++17
51 / 100
1500 ms 20552 KB
#include <bits/stdc++.h>
using namespace std;
 
#include "paint.h"
//#define int long long
#define pi pair<int, int>
#define pii pair<int, pi>
#define fi first
#define se second
#ifdef _WIN32
#define getchar_unlocked _getchar_nolock
#endif
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
 
bool ok[200005];
vector <int> brr[200005], grr[200005];
int dp[200005];
int stuf[200005];
int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {
  for(int i=0;i<M;i++){
	  for(auto j : B[i])brr[j].push_back(i);
  }
  for(int i=0;i<M;i++)stuf[i] = M;
  for(int i=0;i<M-1;i++){
	for(auto j : brr[C[i]])stuf[(j - i + 1000 * M) % M]--;  
  }
  for(int i=M-1;i<N;i++){
	  for(auto j : brr[C[i]])stuf[(j - i + 1000 * M) % M]--;
	  int rv = i - (M - 1) - 1;
	  if(rv >= 0){
		  for(auto j : brr[C[rv]])stuf[(j - rv + 1000 * M) % M]++;
	  }
	  for(int j=0;j<M;j++)if(stuf[j] == 0)ok[i] = 1;
  }
  for(int i = 0; i < M - 1; i++)dp[i] = 2e9;
  for(int i=M - 1;i<N;i++){
	  dp[i] = 2e9;
	  //cout << ok[i] << ' ';
	  if(ok[i]){
		  int tmp= 2e9;
		  if(i == M - 1)tmp = 0;
		  for(int j = i - 1; j >= max(0, i - M); j--)tmp = min(tmp, dp[j]);
		  dp[i] = tmp + 1;
	  }
  }
  return (dp[N - 1] > N ? -1 : dp[N - 1]);
}
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 6 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 6 ms 9588 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 5 ms 9676 KB Output is correct
8 Correct 6 ms 9684 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 5 ms 9664 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9684 KB Output is correct
13 Correct 6 ms 9752 KB Output is correct
14 Correct 6 ms 9712 KB Output is correct
15 Correct 5 ms 9708 KB Output is correct
16 Correct 5 ms 9684 KB Output is correct
17 Correct 6 ms 9712 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
19 Correct 6 ms 9684 KB Output is correct
20 Correct 6 ms 9684 KB Output is correct
21 Correct 6 ms 9684 KB Output is correct
22 Correct 24 ms 14192 KB Output is correct
23 Correct 24 ms 14136 KB Output is correct
24 Correct 24 ms 14184 KB Output is correct
25 Correct 8 ms 9940 KB Output is correct
26 Correct 7 ms 9940 KB Output is correct
27 Correct 8 ms 9876 KB Output is correct
28 Correct 8 ms 9940 KB Output is correct
29 Correct 8 ms 9940 KB Output is correct
30 Correct 8 ms 9984 KB Output is correct
31 Correct 75 ms 11032 KB Output is correct
32 Correct 74 ms 11180 KB Output is correct
33 Correct 73 ms 11072 KB Output is correct
34 Correct 76 ms 11188 KB Output is correct
35 Correct 73 ms 11024 KB Output is correct
36 Correct 75 ms 11028 KB Output is correct
37 Correct 52 ms 14668 KB Output is correct
38 Correct 51 ms 14624 KB Output is correct
39 Correct 53 ms 14692 KB Output is correct
40 Correct 15 ms 10956 KB Output is correct
41 Correct 13 ms 10452 KB Output is correct
42 Correct 17 ms 11092 KB Output is correct
43 Correct 14 ms 10580 KB Output is correct
44 Correct 12 ms 10500 KB Output is correct
45 Correct 17 ms 11108 KB Output is correct
46 Execution timed out 1578 ms 20552 KB Time limit exceeded
47 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 6 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 6 ms 9588 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 5 ms 9684 KB Output is correct
7 Correct 5 ms 9676 KB Output is correct
8 Correct 6 ms 9684 KB Output is correct
9 Correct 5 ms 9684 KB Output is correct
10 Correct 5 ms 9664 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9684 KB Output is correct
13 Correct 6 ms 9752 KB Output is correct
14 Correct 6 ms 9712 KB Output is correct
15 Correct 5 ms 9708 KB Output is correct
16 Correct 5 ms 9684 KB Output is correct
17 Correct 6 ms 9712 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
19 Correct 6 ms 9684 KB Output is correct
20 Correct 6 ms 9684 KB Output is correct
21 Correct 6 ms 9684 KB Output is correct
22 Correct 5 ms 9684 KB Output is correct
23 Correct 5 ms 9684 KB Output is correct
24 Correct 5 ms 9680 KB Output is correct
25 Correct 5 ms 9708 KB Output is correct
26 Correct 5 ms 9708 KB Output is correct
27 Correct 5 ms 9684 KB Output is correct
28 Correct 5 ms 9684 KB Output is correct
29 Correct 5 ms 9684 KB Output is correct
30 Correct 5 ms 9684 KB Output is correct
31 Correct 5 ms 9712 KB Output is correct
32 Correct 5 ms 9708 KB Output is correct
33 Correct 6 ms 9684 KB Output is correct
34 Correct 6 ms 9712 KB Output is correct
35 Correct 6 ms 9684 KB Output is correct
36 Correct 6 ms 9648 KB Output is correct
37 Correct 6 ms 9644 KB Output is correct
38 Correct 6 ms 9704 KB Output is correct
39 Correct 6 ms 9684 KB Output is correct
40 Correct 6 ms 9668 KB Output is correct
41 Correct 5 ms 9672 KB Output is correct
42 Correct 5 ms 9716 KB Output is correct
43 Correct 5 ms 9620 KB Output is correct
44 Correct 6 ms 9624 KB Output is correct
45 Correct 6 ms 9708 KB Output is correct
46 Correct 6 ms 9684 KB Output is correct
47 Correct 5 ms 9652 KB Output is correct
48 Correct 6 ms 9684 KB Output is correct
49 Correct 5 ms 9684 KB Output is correct
50 Correct 6 ms 9684 KB Output is correct
51 Correct 5 ms 9684 KB Output is correct
52 Correct 5 ms 9716 KB Output is correct
53 Correct 5 ms 9684 KB Output is correct
54 Correct 6 ms 9684 KB Output is correct
55 Correct 5 ms 9708 KB Output is correct
56 Correct 5 ms 9684 KB Output is correct
57 Correct 6 ms 9684 KB Output is correct
58 Correct 7 ms 9732 KB Output is correct
59 Correct 5 ms 9700 KB Output is correct
60 Correct 7 ms 9684 KB Output is correct
61 Correct 6 ms 9684 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 6 ms 9684 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 6 ms 9588 KB Output is correct
7 Correct 5 ms 9684 KB Output is correct
8 Correct 5 ms 9684 KB Output is correct
9 Correct 5 ms 9676 KB Output is correct
10 Correct 6 ms 9684 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9664 KB Output is correct
13 Correct 5 ms 9684 KB Output is correct
14 Correct 5 ms 9684 KB Output is correct
15 Correct 6 ms 9752 KB Output is correct
16 Correct 6 ms 9712 KB Output is correct
17 Correct 5 ms 9708 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
19 Correct 6 ms 9712 KB Output is correct
20 Correct 5 ms 9684 KB Output is correct
21 Correct 6 ms 9684 KB Output is correct
22 Correct 6 ms 9684 KB Output is correct
23 Correct 6 ms 9684 KB Output is correct
24 Correct 24 ms 14192 KB Output is correct
25 Correct 24 ms 14136 KB Output is correct
26 Correct 24 ms 14184 KB Output is correct
27 Correct 5 ms 9680 KB Output is correct
28 Correct 5 ms 9708 KB Output is correct
29 Correct 5 ms 9708 KB Output is correct
30 Correct 5 ms 9684 KB Output is correct
31 Correct 5 ms 9684 KB Output is correct
32 Correct 5 ms 9684 KB Output is correct
33 Correct 5 ms 9684 KB Output is correct
34 Correct 5 ms 9712 KB Output is correct
35 Correct 5 ms 9708 KB Output is correct
36 Correct 6 ms 9684 KB Output is correct
37 Correct 6 ms 9712 KB Output is correct
38 Correct 6 ms 9684 KB Output is correct
39 Correct 6 ms 9648 KB Output is correct
40 Correct 6 ms 9644 KB Output is correct
41 Correct 6 ms 9704 KB Output is correct
42 Correct 6 ms 9684 KB Output is correct
43 Correct 6 ms 9668 KB Output is correct
44 Correct 5 ms 9672 KB Output is correct
45 Correct 5 ms 9716 KB Output is correct
46 Correct 5 ms 9620 KB Output is correct
47 Correct 6 ms 9624 KB Output is correct
48 Correct 6 ms 9708 KB Output is correct
49 Correct 6 ms 9684 KB Output is correct
50 Correct 5 ms 9652 KB Output is correct
51 Correct 6 ms 9684 KB Output is correct
52 Correct 5 ms 9684 KB Output is correct
53 Correct 6 ms 9684 KB Output is correct
54 Correct 5 ms 9684 KB Output is correct
55 Correct 5 ms 9716 KB Output is correct
56 Correct 5 ms 9684 KB Output is correct
57 Correct 6 ms 9684 KB Output is correct
58 Correct 5 ms 9708 KB Output is correct
59 Correct 5 ms 9684 KB Output is correct
60 Correct 6 ms 9684 KB Output is correct
61 Correct 7 ms 9732 KB Output is correct
62 Correct 5 ms 9700 KB Output is correct
63 Correct 7 ms 9684 KB Output is correct
64 Correct 6 ms 9684 KB Output is correct
65 Correct 6 ms 9708 KB Output is correct
66 Correct 6 ms 9720 KB Output is correct
67 Correct 6 ms 9708 KB Output is correct
68 Correct 6 ms 9684 KB Output is correct
69 Correct 6 ms 9684 KB Output is correct
70 Correct 8 ms 9956 KB Output is correct
71 Correct 8 ms 9940 KB Output is correct
72 Correct 7 ms 9940 KB Output is correct
73 Correct 7 ms 9856 KB Output is correct
74 Correct 7 ms 9844 KB Output is correct
75 Correct 7 ms 9852 KB Output is correct
76 Correct 23 ms 12884 KB Output is correct
77 Correct 22 ms 13472 KB Output is correct
78 Correct 29 ms 13948 KB Output is correct
79 Correct 7 ms 9652 KB Output is correct
80 Correct 7 ms 9708 KB Output is correct
81 Correct 7 ms 9684 KB Output is correct
82 Correct 8 ms 9684 KB Output is correct
83 Correct 7 ms 9732 KB Output is correct
84 Correct 9 ms 9940 KB Output is correct
85 Correct 9 ms 10008 KB Output is correct
86 Correct 9 ms 9940 KB Output is correct
87 Correct 8 ms 9940 KB Output is correct
88 Correct 8 ms 9940 KB Output is correct
89 Correct 8 ms 9976 KB Output is correct
90 Correct 33 ms 14224 KB Output is correct
91 Correct 33 ms 14320 KB Output is correct
92 Correct 33 ms 14336 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 6 ms 9684 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 6 ms 9588 KB Output is correct
7 Correct 5 ms 9684 KB Output is correct
8 Correct 5 ms 9684 KB Output is correct
9 Correct 5 ms 9676 KB Output is correct
10 Correct 6 ms 9684 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9664 KB Output is correct
13 Correct 5 ms 9684 KB Output is correct
14 Correct 5 ms 9684 KB Output is correct
15 Correct 6 ms 9752 KB Output is correct
16 Correct 6 ms 9712 KB Output is correct
17 Correct 5 ms 9708 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
19 Correct 6 ms 9712 KB Output is correct
20 Correct 5 ms 9684 KB Output is correct
21 Correct 6 ms 9684 KB Output is correct
22 Correct 6 ms 9684 KB Output is correct
23 Correct 6 ms 9684 KB Output is correct
24 Correct 24 ms 14192 KB Output is correct
25 Correct 24 ms 14136 KB Output is correct
26 Correct 24 ms 14184 KB Output is correct
27 Correct 8 ms 9940 KB Output is correct
28 Correct 7 ms 9940 KB Output is correct
29 Correct 8 ms 9876 KB Output is correct
30 Correct 8 ms 9940 KB Output is correct
31 Correct 8 ms 9940 KB Output is correct
32 Correct 8 ms 9984 KB Output is correct
33 Correct 75 ms 11032 KB Output is correct
34 Correct 74 ms 11180 KB Output is correct
35 Correct 73 ms 11072 KB Output is correct
36 Correct 76 ms 11188 KB Output is correct
37 Correct 73 ms 11024 KB Output is correct
38 Correct 75 ms 11028 KB Output is correct
39 Correct 52 ms 14668 KB Output is correct
40 Correct 51 ms 14624 KB Output is correct
41 Correct 53 ms 14692 KB Output is correct
42 Correct 5 ms 9680 KB Output is correct
43 Correct 5 ms 9708 KB Output is correct
44 Correct 5 ms 9708 KB Output is correct
45 Correct 5 ms 9684 KB Output is correct
46 Correct 5 ms 9684 KB Output is correct
47 Correct 5 ms 9684 KB Output is correct
48 Correct 5 ms 9684 KB Output is correct
49 Correct 5 ms 9712 KB Output is correct
50 Correct 5 ms 9708 KB Output is correct
51 Correct 6 ms 9684 KB Output is correct
52 Correct 6 ms 9712 KB Output is correct
53 Correct 6 ms 9684 KB Output is correct
54 Correct 6 ms 9648 KB Output is correct
55 Correct 6 ms 9644 KB Output is correct
56 Correct 6 ms 9704 KB Output is correct
57 Correct 6 ms 9684 KB Output is correct
58 Correct 6 ms 9668 KB Output is correct
59 Correct 5 ms 9672 KB Output is correct
60 Correct 5 ms 9716 KB Output is correct
61 Correct 5 ms 9620 KB Output is correct
62 Correct 6 ms 9624 KB Output is correct
63 Correct 6 ms 9708 KB Output is correct
64 Correct 6 ms 9684 KB Output is correct
65 Correct 5 ms 9652 KB Output is correct
66 Correct 6 ms 9684 KB Output is correct
67 Correct 5 ms 9684 KB Output is correct
68 Correct 6 ms 9684 KB Output is correct
69 Correct 5 ms 9684 KB Output is correct
70 Correct 5 ms 9716 KB Output is correct
71 Correct 5 ms 9684 KB Output is correct
72 Correct 6 ms 9684 KB Output is correct
73 Correct 5 ms 9708 KB Output is correct
74 Correct 5 ms 9684 KB Output is correct
75 Correct 6 ms 9684 KB Output is correct
76 Correct 7 ms 9732 KB Output is correct
77 Correct 5 ms 9700 KB Output is correct
78 Correct 7 ms 9684 KB Output is correct
79 Correct 6 ms 9684 KB Output is correct
80 Correct 6 ms 9708 KB Output is correct
81 Correct 6 ms 9720 KB Output is correct
82 Correct 6 ms 9708 KB Output is correct
83 Correct 6 ms 9684 KB Output is correct
84 Correct 6 ms 9684 KB Output is correct
85 Correct 8 ms 9956 KB Output is correct
86 Correct 8 ms 9940 KB Output is correct
87 Correct 7 ms 9940 KB Output is correct
88 Correct 7 ms 9856 KB Output is correct
89 Correct 7 ms 9844 KB Output is correct
90 Correct 7 ms 9852 KB Output is correct
91 Correct 23 ms 12884 KB Output is correct
92 Correct 22 ms 13472 KB Output is correct
93 Correct 29 ms 13948 KB Output is correct
94 Correct 7 ms 9652 KB Output is correct
95 Correct 7 ms 9708 KB Output is correct
96 Correct 7 ms 9684 KB Output is correct
97 Correct 8 ms 9684 KB Output is correct
98 Correct 7 ms 9732 KB Output is correct
99 Correct 9 ms 9940 KB Output is correct
100 Correct 9 ms 10008 KB Output is correct
101 Correct 9 ms 9940 KB Output is correct
102 Correct 8 ms 9940 KB Output is correct
103 Correct 8 ms 9940 KB Output is correct
104 Correct 8 ms 9976 KB Output is correct
105 Correct 33 ms 14224 KB Output is correct
106 Correct 33 ms 14320 KB Output is correct
107 Correct 33 ms 14336 KB Output is correct
108 Correct 8 ms 9940 KB Output is correct
109 Correct 167 ms 9940 KB Output is correct
110 Correct 95 ms 10064 KB Output is correct
111 Correct 72 ms 9888 KB Output is correct
112 Correct 84 ms 9948 KB Output is correct
113 Correct 60 ms 9932 KB Output is correct
114 Correct 36 ms 11396 KB Output is correct
115 Correct 19 ms 11220 KB Output is correct
116 Correct 46 ms 11632 KB Output is correct
117 Correct 29 ms 11304 KB Output is correct
118 Correct 21 ms 11488 KB Output is correct
119 Correct 49 ms 11064 KB Output is correct
120 Correct 39 ms 12748 KB Output is correct
121 Correct 43 ms 10356 KB Output is correct
122 Correct 32 ms 13084 KB Output is correct
123 Correct 21 ms 10324 KB Output is correct
124 Correct 32 ms 13724 KB Output is correct
125 Correct 19 ms 10604 KB Output is correct
126 Correct 12 ms 10660 KB Output is correct
127 Correct 23 ms 10964 KB Output is correct
128 Correct 14 ms 10608 KB Output is correct
129 Correct 19 ms 10656 KB Output is correct
130 Correct 8 ms 9940 KB Output is correct
131 Correct 245 ms 9984 KB Output is correct
132 Correct 169 ms 9996 KB Output is correct
133 Correct 150 ms 10008 KB Output is correct
134 Correct 133 ms 10024 KB Output is correct
135 Correct 114 ms 10032 KB Output is correct
136 Correct 83 ms 11980 KB Output is correct
137 Correct 84 ms 11872 KB Output is correct
138 Correct 86 ms 11948 KB Output is correct
139 Correct 84 ms 12040 KB Output is correct
140 Correct 85 ms 11888 KB Output is correct
141 Correct 83 ms 11936 KB Output is correct
142 Correct 62 ms 14828 KB Output is correct
143 Correct 76 ms 10812 KB Output is correct
144 Correct 61 ms 14764 KB Output is correct
145 Correct 73 ms 10828 KB Output is correct
146 Correct 64 ms 14744 KB Output is correct
147 Correct 73 ms 10828 KB Output is correct
148 Correct 40 ms 11216 KB Output is correct
149 Correct 30 ms 11128 KB Output is correct
150 Correct 23 ms 11124 KB Output is correct
151 Correct 21 ms 11116 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9684 KB Output is correct
2 Correct 5 ms 9684 KB Output is correct
3 Correct 5 ms 9684 KB Output is correct
4 Correct 6 ms 9684 KB Output is correct
5 Correct 5 ms 9684 KB Output is correct
6 Correct 6 ms 9588 KB Output is correct
7 Correct 5 ms 9684 KB Output is correct
8 Correct 5 ms 9684 KB Output is correct
9 Correct 5 ms 9676 KB Output is correct
10 Correct 6 ms 9684 KB Output is correct
11 Correct 5 ms 9684 KB Output is correct
12 Correct 5 ms 9664 KB Output is correct
13 Correct 5 ms 9684 KB Output is correct
14 Correct 5 ms 9684 KB Output is correct
15 Correct 6 ms 9752 KB Output is correct
16 Correct 6 ms 9712 KB Output is correct
17 Correct 5 ms 9708 KB Output is correct
18 Correct 5 ms 9684 KB Output is correct
19 Correct 6 ms 9712 KB Output is correct
20 Correct 5 ms 9684 KB Output is correct
21 Correct 6 ms 9684 KB Output is correct
22 Correct 6 ms 9684 KB Output is correct
23 Correct 6 ms 9684 KB Output is correct
24 Correct 24 ms 14192 KB Output is correct
25 Correct 24 ms 14136 KB Output is correct
26 Correct 24 ms 14184 KB Output is correct
27 Correct 8 ms 9940 KB Output is correct
28 Correct 7 ms 9940 KB Output is correct
29 Correct 8 ms 9876 KB Output is correct
30 Correct 8 ms 9940 KB Output is correct
31 Correct 8 ms 9940 KB Output is correct
32 Correct 8 ms 9984 KB Output is correct
33 Correct 75 ms 11032 KB Output is correct
34 Correct 74 ms 11180 KB Output is correct
35 Correct 73 ms 11072 KB Output is correct
36 Correct 76 ms 11188 KB Output is correct
37 Correct 73 ms 11024 KB Output is correct
38 Correct 75 ms 11028 KB Output is correct
39 Correct 52 ms 14668 KB Output is correct
40 Correct 51 ms 14624 KB Output is correct
41 Correct 53 ms 14692 KB Output is correct
42 Correct 15 ms 10956 KB Output is correct
43 Correct 13 ms 10452 KB Output is correct
44 Correct 17 ms 11092 KB Output is correct
45 Correct 14 ms 10580 KB Output is correct
46 Correct 12 ms 10500 KB Output is correct
47 Correct 17 ms 11108 KB Output is correct
48 Execution timed out 1578 ms 20552 KB Time limit exceeded
49 Halted 0 ms 0 KB -