답안 #409918

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
409918 2021-05-21T19:05:38 Z Blistering_Barnacles 벽 칠하기 (APIO20_paint) C++11
51 / 100
1024 ms 40132 KB
#include "paint.h"
//apig's property
//Happiness can be found, even in the darkest of times, if one only remembers to turn on the light
//El Pueblo Unido Jamas Sera Vencido
//The saddest thing about betrayal? is that it never comes from your enemies
//Do or do not... there is no try
//Billions of bilious blue blistering barnacles in a thundering typhoon!
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0) , cin.tie(0) , cout.tie(0)
#define F first
#define S second
#define pb push_back
#define vll vector< ll >
#define vi vector< int >
#define pll pair< ll , ll >
#define pi pair< int , int >
#define all(s) s.begin() , s.end()
#define sz(s) s.size()
#define str string
#define md ((s + e) / 2)
#define mid ((l + r) / 2)
#define msdp(dp) memset(dp , -1 , sizeof dp)
#define mscl(dp) memset(dp , 0 , sizeof dp)
#define Co continue
#define R return
#define Br break
#define lx node * 2
#define rx node * 2 + 1
#define br(o) o ; break
#define co(o) o ; continue
using namespace std;
typedef int ll;
ll q, dp[20005] , a[555555] , b[555555] , ok[55555] , k, l, m, n, o, p;
map < ll , ll > mp[20005];
vll adj[555555] , adj2[555555];
const ll mod = 1e9+7;
str s;
vll  c ;
void do_something(ll idxn , ll idxm , ll cnt){
   // cout << cnt << " " ;
    if(cnt >= m)ok[idxn - m] = 1 ;
    if(idxn >= n)R ;
    if(!mp[idxm][c[idxn]])R ;
    do_something(idxn + 1 , (idxm + 1) % m , cnt + 1) ;
    R ;
}
ll mem(ll i){
    if(i >= n)R 0 ;
    ll &r = dp[i] ;
    if(r != -1)R r ;
    r = mod ;
    if(ok[i]){
        for(ll j = 0 ; j <= m ; j++)r = min(r , mem(i + j) + 1) ;
    }
    R r ;
}
int minimumInstructions(int N, int M, int K, vector<int> C, std::vector<int> A, std::vector<std::vector<int>> B) {
    msdp(dp) ;
    c = C ;
    n = N ;
    m = M ;
    for(ll i = 0 ; i < m ; i++){
        //cout << i << " " ;
        for(ll j = 0 ; j < A[i] ; j++){
            adj2[B[i][j]].pb(i) ;
            mp[i][B[i][j]]++ ;
        }
    }
    for(ll i = 0 ; i <= n - m ; i++){
        if(ok[i])continue ;
        for(auto u : adj2[c[i]]){
            do_something(i , u , 0) ;
            //if(ok[i])break ;
        }
        //cout << ok[i] << " " ;
    }
    ll ans = mem(0) ;
    R (ans < mod ? ans : -1) ;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 27340 KB Output is correct
2 Correct 15 ms 27340 KB Output is correct
3 Correct 15 ms 27348 KB Output is correct
4 Correct 16 ms 27416 KB Output is correct
5 Correct 16 ms 27332 KB Output is correct
6 Correct 16 ms 27340 KB Output is correct
7 Correct 16 ms 27336 KB Output is correct
8 Correct 15 ms 27340 KB Output is correct
9 Correct 15 ms 27328 KB Output is correct
10 Correct 16 ms 27420 KB Output is correct
11 Correct 17 ms 27416 KB Output is correct
12 Correct 16 ms 27376 KB Output is correct
13 Correct 17 ms 27428 KB Output is correct
14 Correct 16 ms 27468 KB Output is correct
15 Correct 17 ms 27468 KB Output is correct
16 Correct 16 ms 27468 KB Output is correct
17 Correct 17 ms 27456 KB Output is correct
18 Correct 16 ms 27484 KB Output is correct
19 Correct 17 ms 27500 KB Output is correct
20 Correct 16 ms 27468 KB Output is correct
21 Correct 16 ms 27472 KB Output is correct
22 Correct 61 ms 36016 KB Output is correct
23 Correct 56 ms 36004 KB Output is correct
24 Correct 56 ms 35936 KB Output is correct
25 Correct 19 ms 28664 KB Output is correct
26 Correct 20 ms 28560 KB Output is correct
27 Correct 18 ms 27728 KB Output is correct
28 Correct 18 ms 27724 KB Output is correct
29 Correct 18 ms 27668 KB Output is correct
30 Correct 26 ms 27596 KB Output is correct
31 Correct 196 ms 30396 KB Output is correct
32 Correct 197 ms 30396 KB Output is correct
33 Correct 194 ms 30404 KB Output is correct
34 Correct 194 ms 30356 KB Output is correct
35 Correct 193 ms 30392 KB Output is correct
36 Correct 195 ms 30396 KB Output is correct
37 Correct 69 ms 37164 KB Output is correct
38 Correct 70 ms 37188 KB Output is correct
39 Correct 73 ms 37232 KB Output is correct
40 Incorrect 25 ms 29772 KB Output isn't correct
41 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 27340 KB Output is correct
2 Correct 15 ms 27340 KB Output is correct
3 Correct 15 ms 27348 KB Output is correct
4 Correct 16 ms 27416 KB Output is correct
5 Correct 16 ms 27332 KB Output is correct
6 Correct 16 ms 27340 KB Output is correct
7 Correct 16 ms 27336 KB Output is correct
8 Correct 15 ms 27340 KB Output is correct
9 Correct 15 ms 27328 KB Output is correct
10 Correct 16 ms 27420 KB Output is correct
11 Correct 17 ms 27416 KB Output is correct
12 Correct 16 ms 27376 KB Output is correct
13 Correct 17 ms 27428 KB Output is correct
14 Correct 16 ms 27468 KB Output is correct
15 Correct 17 ms 27468 KB Output is correct
16 Correct 16 ms 27468 KB Output is correct
17 Correct 17 ms 27456 KB Output is correct
18 Correct 16 ms 27484 KB Output is correct
19 Correct 17 ms 27500 KB Output is correct
20 Correct 16 ms 27468 KB Output is correct
21 Correct 16 ms 27472 KB Output is correct
22 Correct 17 ms 27340 KB Output is correct
23 Correct 19 ms 27340 KB Output is correct
24 Correct 17 ms 27344 KB Output is correct
25 Correct 18 ms 27416 KB Output is correct
26 Correct 16 ms 27340 KB Output is correct
27 Correct 16 ms 27408 KB Output is correct
28 Correct 17 ms 27424 KB Output is correct
29 Correct 16 ms 27340 KB Output is correct
30 Correct 17 ms 27340 KB Output is correct
31 Correct 16 ms 27340 KB Output is correct
32 Correct 16 ms 27436 KB Output is correct
33 Correct 16 ms 27368 KB Output is correct
34 Correct 16 ms 27400 KB Output is correct
35 Correct 16 ms 27340 KB Output is correct
36 Correct 16 ms 27468 KB Output is correct
37 Correct 17 ms 27348 KB Output is correct
38 Correct 16 ms 27468 KB Output is correct
39 Correct 16 ms 27460 KB Output is correct
40 Correct 17 ms 27520 KB Output is correct
41 Correct 16 ms 27340 KB Output is correct
42 Correct 16 ms 27468 KB Output is correct
43 Correct 16 ms 27340 KB Output is correct
44 Correct 18 ms 27340 KB Output is correct
45 Correct 16 ms 27340 KB Output is correct
46 Correct 16 ms 27420 KB Output is correct
47 Correct 17 ms 27340 KB Output is correct
48 Correct 17 ms 27340 KB Output is correct
49 Correct 16 ms 27388 KB Output is correct
50 Correct 16 ms 27468 KB Output is correct
51 Correct 16 ms 27436 KB Output is correct
52 Correct 16 ms 27476 KB Output is correct
53 Correct 17 ms 27468 KB Output is correct
54 Correct 18 ms 27492 KB Output is correct
55 Correct 17 ms 27488 KB Output is correct
56 Correct 17 ms 27596 KB Output is correct
57 Correct 17 ms 27468 KB Output is correct
58 Correct 16 ms 27444 KB Output is correct
59 Correct 16 ms 27456 KB Output is correct
60 Correct 16 ms 27468 KB Output is correct
61 Correct 16 ms 27396 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 27340 KB Output is correct
2 Correct 19 ms 27340 KB Output is correct
3 Correct 16 ms 27340 KB Output is correct
4 Correct 15 ms 27340 KB Output is correct
5 Correct 15 ms 27348 KB Output is correct
6 Correct 16 ms 27416 KB Output is correct
7 Correct 16 ms 27332 KB Output is correct
8 Correct 16 ms 27340 KB Output is correct
9 Correct 16 ms 27336 KB Output is correct
10 Correct 15 ms 27340 KB Output is correct
11 Correct 15 ms 27328 KB Output is correct
12 Correct 16 ms 27420 KB Output is correct
13 Correct 17 ms 27416 KB Output is correct
14 Correct 16 ms 27376 KB Output is correct
15 Correct 17 ms 27428 KB Output is correct
16 Correct 16 ms 27468 KB Output is correct
17 Correct 17 ms 27468 KB Output is correct
18 Correct 16 ms 27468 KB Output is correct
19 Correct 17 ms 27456 KB Output is correct
20 Correct 16 ms 27484 KB Output is correct
21 Correct 17 ms 27500 KB Output is correct
22 Correct 16 ms 27468 KB Output is correct
23 Correct 16 ms 27472 KB Output is correct
24 Correct 61 ms 36016 KB Output is correct
25 Correct 56 ms 36004 KB Output is correct
26 Correct 56 ms 35936 KB Output is correct
27 Correct 17 ms 27344 KB Output is correct
28 Correct 18 ms 27416 KB Output is correct
29 Correct 16 ms 27340 KB Output is correct
30 Correct 16 ms 27408 KB Output is correct
31 Correct 17 ms 27424 KB Output is correct
32 Correct 16 ms 27340 KB Output is correct
33 Correct 17 ms 27340 KB Output is correct
34 Correct 16 ms 27340 KB Output is correct
35 Correct 16 ms 27436 KB Output is correct
36 Correct 16 ms 27368 KB Output is correct
37 Correct 16 ms 27400 KB Output is correct
38 Correct 16 ms 27340 KB Output is correct
39 Correct 16 ms 27468 KB Output is correct
40 Correct 17 ms 27348 KB Output is correct
41 Correct 16 ms 27468 KB Output is correct
42 Correct 16 ms 27460 KB Output is correct
43 Correct 17 ms 27520 KB Output is correct
44 Correct 16 ms 27340 KB Output is correct
45 Correct 16 ms 27468 KB Output is correct
46 Correct 16 ms 27340 KB Output is correct
47 Correct 18 ms 27340 KB Output is correct
48 Correct 16 ms 27340 KB Output is correct
49 Correct 16 ms 27420 KB Output is correct
50 Correct 17 ms 27340 KB Output is correct
51 Correct 17 ms 27340 KB Output is correct
52 Correct 16 ms 27388 KB Output is correct
53 Correct 16 ms 27468 KB Output is correct
54 Correct 16 ms 27436 KB Output is correct
55 Correct 16 ms 27476 KB Output is correct
56 Correct 17 ms 27468 KB Output is correct
57 Correct 18 ms 27492 KB Output is correct
58 Correct 17 ms 27488 KB Output is correct
59 Correct 17 ms 27596 KB Output is correct
60 Correct 17 ms 27468 KB Output is correct
61 Correct 16 ms 27444 KB Output is correct
62 Correct 16 ms 27456 KB Output is correct
63 Correct 16 ms 27468 KB Output is correct
64 Correct 16 ms 27396 KB Output is correct
65 Correct 18 ms 27444 KB Output is correct
66 Correct 18 ms 27340 KB Output is correct
67 Correct 19 ms 27352 KB Output is correct
68 Correct 17 ms 27372 KB Output is correct
69 Correct 17 ms 27476 KB Output is correct
70 Correct 19 ms 27980 KB Output is correct
71 Correct 20 ms 28108 KB Output is correct
72 Correct 20 ms 28036 KB Output is correct
73 Correct 21 ms 27728 KB Output is correct
74 Correct 20 ms 27968 KB Output is correct
75 Correct 19 ms 27916 KB Output is correct
76 Correct 58 ms 35340 KB Output is correct
77 Correct 60 ms 36164 KB Output is correct
78 Correct 73 ms 37604 KB Output is correct
79 Correct 17 ms 27424 KB Output is correct
80 Correct 18 ms 27468 KB Output is correct
81 Correct 17 ms 27468 KB Output is correct
82 Correct 18 ms 27468 KB Output is correct
83 Correct 18 ms 27512 KB Output is correct
84 Correct 21 ms 28252 KB Output is correct
85 Correct 22 ms 28272 KB Output is correct
86 Correct 21 ms 28228 KB Output is correct
87 Correct 21 ms 28268 KB Output is correct
88 Correct 20 ms 28264 KB Output is correct
89 Correct 20 ms 28300 KB Output is correct
90 Correct 78 ms 38468 KB Output is correct
91 Correct 83 ms 38596 KB Output is correct
92 Correct 80 ms 38524 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 27340 KB Output is correct
2 Correct 19 ms 27340 KB Output is correct
3 Correct 16 ms 27340 KB Output is correct
4 Correct 15 ms 27340 KB Output is correct
5 Correct 15 ms 27348 KB Output is correct
6 Correct 16 ms 27416 KB Output is correct
7 Correct 16 ms 27332 KB Output is correct
8 Correct 16 ms 27340 KB Output is correct
9 Correct 16 ms 27336 KB Output is correct
10 Correct 15 ms 27340 KB Output is correct
11 Correct 15 ms 27328 KB Output is correct
12 Correct 16 ms 27420 KB Output is correct
13 Correct 17 ms 27416 KB Output is correct
14 Correct 16 ms 27376 KB Output is correct
15 Correct 17 ms 27428 KB Output is correct
16 Correct 16 ms 27468 KB Output is correct
17 Correct 17 ms 27468 KB Output is correct
18 Correct 16 ms 27468 KB Output is correct
19 Correct 17 ms 27456 KB Output is correct
20 Correct 16 ms 27484 KB Output is correct
21 Correct 17 ms 27500 KB Output is correct
22 Correct 16 ms 27468 KB Output is correct
23 Correct 16 ms 27472 KB Output is correct
24 Correct 61 ms 36016 KB Output is correct
25 Correct 56 ms 36004 KB Output is correct
26 Correct 56 ms 35936 KB Output is correct
27 Correct 19 ms 28664 KB Output is correct
28 Correct 20 ms 28560 KB Output is correct
29 Correct 18 ms 27728 KB Output is correct
30 Correct 18 ms 27724 KB Output is correct
31 Correct 18 ms 27668 KB Output is correct
32 Correct 26 ms 27596 KB Output is correct
33 Correct 196 ms 30396 KB Output is correct
34 Correct 197 ms 30396 KB Output is correct
35 Correct 194 ms 30404 KB Output is correct
36 Correct 194 ms 30356 KB Output is correct
37 Correct 193 ms 30392 KB Output is correct
38 Correct 195 ms 30396 KB Output is correct
39 Correct 69 ms 37164 KB Output is correct
40 Correct 70 ms 37188 KB Output is correct
41 Correct 73 ms 37232 KB Output is correct
42 Correct 17 ms 27344 KB Output is correct
43 Correct 18 ms 27416 KB Output is correct
44 Correct 16 ms 27340 KB Output is correct
45 Correct 16 ms 27408 KB Output is correct
46 Correct 17 ms 27424 KB Output is correct
47 Correct 16 ms 27340 KB Output is correct
48 Correct 17 ms 27340 KB Output is correct
49 Correct 16 ms 27340 KB Output is correct
50 Correct 16 ms 27436 KB Output is correct
51 Correct 16 ms 27368 KB Output is correct
52 Correct 16 ms 27400 KB Output is correct
53 Correct 16 ms 27340 KB Output is correct
54 Correct 16 ms 27468 KB Output is correct
55 Correct 17 ms 27348 KB Output is correct
56 Correct 16 ms 27468 KB Output is correct
57 Correct 16 ms 27460 KB Output is correct
58 Correct 17 ms 27520 KB Output is correct
59 Correct 16 ms 27340 KB Output is correct
60 Correct 16 ms 27468 KB Output is correct
61 Correct 16 ms 27340 KB Output is correct
62 Correct 18 ms 27340 KB Output is correct
63 Correct 16 ms 27340 KB Output is correct
64 Correct 16 ms 27420 KB Output is correct
65 Correct 17 ms 27340 KB Output is correct
66 Correct 17 ms 27340 KB Output is correct
67 Correct 16 ms 27388 KB Output is correct
68 Correct 16 ms 27468 KB Output is correct
69 Correct 16 ms 27436 KB Output is correct
70 Correct 16 ms 27476 KB Output is correct
71 Correct 17 ms 27468 KB Output is correct
72 Correct 18 ms 27492 KB Output is correct
73 Correct 17 ms 27488 KB Output is correct
74 Correct 17 ms 27596 KB Output is correct
75 Correct 17 ms 27468 KB Output is correct
76 Correct 16 ms 27444 KB Output is correct
77 Correct 16 ms 27456 KB Output is correct
78 Correct 16 ms 27468 KB Output is correct
79 Correct 16 ms 27396 KB Output is correct
80 Correct 18 ms 27444 KB Output is correct
81 Correct 18 ms 27340 KB Output is correct
82 Correct 19 ms 27352 KB Output is correct
83 Correct 17 ms 27372 KB Output is correct
84 Correct 17 ms 27476 KB Output is correct
85 Correct 19 ms 27980 KB Output is correct
86 Correct 20 ms 28108 KB Output is correct
87 Correct 20 ms 28036 KB Output is correct
88 Correct 21 ms 27728 KB Output is correct
89 Correct 20 ms 27968 KB Output is correct
90 Correct 19 ms 27916 KB Output is correct
91 Correct 58 ms 35340 KB Output is correct
92 Correct 60 ms 36164 KB Output is correct
93 Correct 73 ms 37604 KB Output is correct
94 Correct 17 ms 27424 KB Output is correct
95 Correct 18 ms 27468 KB Output is correct
96 Correct 17 ms 27468 KB Output is correct
97 Correct 18 ms 27468 KB Output is correct
98 Correct 18 ms 27512 KB Output is correct
99 Correct 21 ms 28252 KB Output is correct
100 Correct 22 ms 28272 KB Output is correct
101 Correct 21 ms 28228 KB Output is correct
102 Correct 21 ms 28268 KB Output is correct
103 Correct 20 ms 28264 KB Output is correct
104 Correct 20 ms 28300 KB Output is correct
105 Correct 78 ms 38468 KB Output is correct
106 Correct 83 ms 38596 KB Output is correct
107 Correct 80 ms 38524 KB Output is correct
108 Correct 20 ms 28576 KB Output is correct
109 Correct 107 ms 28372 KB Output is correct
110 Correct 207 ms 27664 KB Output is correct
111 Correct 125 ms 27784 KB Output is correct
112 Correct 186 ms 27812 KB Output is correct
113 Correct 126 ms 27892 KB Output is correct
114 Correct 85 ms 31940 KB Output is correct
115 Correct 44 ms 32076 KB Output is correct
116 Correct 110 ms 33184 KB Output is correct
117 Correct 70 ms 31804 KB Output is correct
118 Correct 48 ms 32536 KB Output is correct
119 Correct 127 ms 31124 KB Output is correct
120 Correct 58 ms 34712 KB Output is correct
121 Correct 111 ms 29004 KB Output is correct
122 Correct 79 ms 36672 KB Output is correct
123 Correct 52 ms 28980 KB Output is correct
124 Correct 94 ms 37788 KB Output is correct
125 Correct 41 ms 29892 KB Output is correct
126 Correct 44 ms 29388 KB Output is correct
127 Correct 354 ms 29824 KB Output is correct
128 Correct 78 ms 29124 KB Output is correct
129 Correct 101 ms 29228 KB Output is correct
130 Correct 18 ms 28568 KB Output is correct
131 Correct 145 ms 28612 KB Output is correct
132 Correct 331 ms 27844 KB Output is correct
133 Correct 223 ms 27876 KB Output is correct
134 Correct 255 ms 27940 KB Output is correct
135 Correct 236 ms 28024 KB Output is correct
136 Correct 211 ms 33732 KB Output is correct
137 Correct 216 ms 33720 KB Output is correct
138 Correct 216 ms 33792 KB Output is correct
139 Correct 214 ms 33636 KB Output is correct
140 Correct 215 ms 33732 KB Output is correct
141 Correct 215 ms 33720 KB Output is correct
142 Correct 100 ms 40124 KB Output is correct
143 Correct 194 ms 30172 KB Output is correct
144 Correct 99 ms 40132 KB Output is correct
145 Correct 196 ms 30292 KB Output is correct
146 Correct 102 ms 40048 KB Output is correct
147 Correct 198 ms 30168 KB Output is correct
148 Correct 1024 ms 30172 KB Output is correct
149 Correct 713 ms 30276 KB Output is correct
150 Correct 441 ms 30140 KB Output is correct
151 Correct 287 ms 30020 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 27340 KB Output is correct
2 Correct 19 ms 27340 KB Output is correct
3 Correct 16 ms 27340 KB Output is correct
4 Correct 15 ms 27340 KB Output is correct
5 Correct 15 ms 27348 KB Output is correct
6 Correct 16 ms 27416 KB Output is correct
7 Correct 16 ms 27332 KB Output is correct
8 Correct 16 ms 27340 KB Output is correct
9 Correct 16 ms 27336 KB Output is correct
10 Correct 15 ms 27340 KB Output is correct
11 Correct 15 ms 27328 KB Output is correct
12 Correct 16 ms 27420 KB Output is correct
13 Correct 17 ms 27416 KB Output is correct
14 Correct 16 ms 27376 KB Output is correct
15 Correct 17 ms 27428 KB Output is correct
16 Correct 16 ms 27468 KB Output is correct
17 Correct 17 ms 27468 KB Output is correct
18 Correct 16 ms 27468 KB Output is correct
19 Correct 17 ms 27456 KB Output is correct
20 Correct 16 ms 27484 KB Output is correct
21 Correct 17 ms 27500 KB Output is correct
22 Correct 16 ms 27468 KB Output is correct
23 Correct 16 ms 27472 KB Output is correct
24 Correct 61 ms 36016 KB Output is correct
25 Correct 56 ms 36004 KB Output is correct
26 Correct 56 ms 35936 KB Output is correct
27 Correct 19 ms 28664 KB Output is correct
28 Correct 20 ms 28560 KB Output is correct
29 Correct 18 ms 27728 KB Output is correct
30 Correct 18 ms 27724 KB Output is correct
31 Correct 18 ms 27668 KB Output is correct
32 Correct 26 ms 27596 KB Output is correct
33 Correct 196 ms 30396 KB Output is correct
34 Correct 197 ms 30396 KB Output is correct
35 Correct 194 ms 30404 KB Output is correct
36 Correct 194 ms 30356 KB Output is correct
37 Correct 193 ms 30392 KB Output is correct
38 Correct 195 ms 30396 KB Output is correct
39 Correct 69 ms 37164 KB Output is correct
40 Correct 70 ms 37188 KB Output is correct
41 Correct 73 ms 37232 KB Output is correct
42 Incorrect 25 ms 29772 KB Output isn't correct
43 Halted 0 ms 0 KB -