Submission #409906

# Submission time Handle Problem Language Result Execution time Memory
409906 2021-05-21T18:55:22 Z Blistering_Barnacles Painting Walls (APIO20_paint) C++11
28 / 100
1500 ms 32856 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[500005] , a[555555] , b[555555] , ok[55555] , k, l, m, n, o, p;
map < ll , ll > mp;
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(find(all(adj2[c[idxn]]) , idxm) == adj2[c[idxn]].end())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++){
            adj[i].pb(B[i][j]) , adj2[B[i][j]].pb(i) ;
        }
    }
    for(ll i = 0 ; i <= n - m ; i++){
        if(ok[i])C ;
        for(auto u : adj2[c[i]]){
            do_something(i , u , 0) ;
            if(ok[i])B ;
        }
        //cout << ok[i] << " " ;
    }
    ll ans = mem(0) ;
    R (ans < mod ? ans : -1) ;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:69:18: warning: statement has no effect [-Wunused-value]
   69 |         if(ok[i])C ;
      |                  ^
paint.cpp:72:22: warning: statement has no effect [-Wunused-value]
   72 |             if(ok[i])B ;
      |                      ^
# Verdict Execution time Memory Grader output
1 Correct 15 ms 28256 KB Output is correct
2 Correct 17 ms 28236 KB Output is correct
3 Correct 17 ms 28320 KB Output is correct
4 Correct 16 ms 28352 KB Output is correct
5 Correct 15 ms 28236 KB Output is correct
6 Correct 16 ms 28420 KB Output is correct
7 Correct 16 ms 28364 KB Output is correct
8 Correct 16 ms 28364 KB Output is correct
9 Correct 16 ms 28332 KB Output is correct
10 Correct 15 ms 28364 KB Output is correct
11 Correct 16 ms 28324 KB Output is correct
12 Correct 16 ms 28304 KB Output is correct
13 Correct 17 ms 28296 KB Output is correct
14 Correct 17 ms 28336 KB Output is correct
15 Correct 17 ms 28348 KB Output is correct
16 Correct 18 ms 28364 KB Output is correct
17 Correct 17 ms 28344 KB Output is correct
18 Correct 17 ms 28364 KB Output is correct
19 Correct 16 ms 28400 KB Output is correct
20 Correct 16 ms 28364 KB Output is correct
21 Correct 16 ms 28304 KB Output is correct
22 Correct 47 ms 32784 KB Output is correct
23 Correct 38 ms 32748 KB Output is correct
24 Correct 45 ms 32692 KB Output is correct
25 Correct 1135 ms 29536 KB Output is correct
26 Correct 1124 ms 29508 KB Output is correct
27 Correct 18 ms 28620 KB Output is correct
28 Correct 19 ms 28660 KB Output is correct
29 Correct 18 ms 28580 KB Output is correct
30 Correct 19 ms 28620 KB Output is correct
31 Execution timed out 1598 ms 29604 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 15 ms 28256 KB Output is correct
2 Correct 17 ms 28236 KB Output is correct
3 Correct 17 ms 28320 KB Output is correct
4 Correct 16 ms 28352 KB Output is correct
5 Correct 15 ms 28236 KB Output is correct
6 Correct 16 ms 28420 KB Output is correct
7 Correct 16 ms 28364 KB Output is correct
8 Correct 16 ms 28364 KB Output is correct
9 Correct 16 ms 28332 KB Output is correct
10 Correct 15 ms 28364 KB Output is correct
11 Correct 16 ms 28324 KB Output is correct
12 Correct 16 ms 28304 KB Output is correct
13 Correct 17 ms 28296 KB Output is correct
14 Correct 17 ms 28336 KB Output is correct
15 Correct 17 ms 28348 KB Output is correct
16 Correct 18 ms 28364 KB Output is correct
17 Correct 17 ms 28344 KB Output is correct
18 Correct 17 ms 28364 KB Output is correct
19 Correct 16 ms 28400 KB Output is correct
20 Correct 16 ms 28364 KB Output is correct
21 Correct 16 ms 28304 KB Output is correct
22 Correct 16 ms 28252 KB Output is correct
23 Correct 15 ms 28272 KB Output is correct
24 Correct 15 ms 28236 KB Output is correct
25 Correct 17 ms 28296 KB Output is correct
26 Correct 15 ms 28236 KB Output is correct
27 Correct 16 ms 28236 KB Output is correct
28 Correct 31 ms 28352 KB Output is correct
29 Correct 17 ms 28236 KB Output is correct
30 Correct 16 ms 28296 KB Output is correct
31 Correct 20 ms 28328 KB Output is correct
32 Correct 18 ms 28236 KB Output is correct
33 Correct 18 ms 28328 KB Output is correct
34 Correct 17 ms 28364 KB Output is correct
35 Correct 17 ms 28308 KB Output is correct
36 Correct 16 ms 28364 KB Output is correct
37 Correct 16 ms 28336 KB Output is correct
38 Correct 16 ms 28352 KB Output is correct
39 Correct 19 ms 28340 KB Output is correct
40 Correct 18 ms 28372 KB Output is correct
41 Correct 17 ms 28380 KB Output is correct
42 Correct 16 ms 28364 KB Output is correct
43 Correct 16 ms 28344 KB Output is correct
44 Correct 19 ms 28348 KB Output is correct
45 Correct 67 ms 28340 KB Output is correct
46 Correct 16 ms 28296 KB Output is correct
47 Correct 16 ms 28364 KB Output is correct
48 Correct 17 ms 28344 KB Output is correct
49 Correct 16 ms 28372 KB Output is correct
50 Correct 17 ms 28364 KB Output is correct
51 Correct 17 ms 28348 KB Output is correct
52 Correct 17 ms 28336 KB Output is correct
53 Correct 17 ms 28360 KB Output is correct
54 Correct 17 ms 28364 KB Output is correct
55 Correct 17 ms 28364 KB Output is correct
56 Correct 16 ms 28396 KB Output is correct
57 Correct 17 ms 28288 KB Output is correct
58 Correct 16 ms 28364 KB Output is correct
59 Correct 19 ms 28404 KB Output is correct
60 Correct 16 ms 28364 KB Output is correct
61 Correct 17 ms 28400 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 28252 KB Output is correct
2 Correct 15 ms 28272 KB Output is correct
3 Correct 15 ms 28256 KB Output is correct
4 Correct 17 ms 28236 KB Output is correct
5 Correct 17 ms 28320 KB Output is correct
6 Correct 16 ms 28352 KB Output is correct
7 Correct 15 ms 28236 KB Output is correct
8 Correct 16 ms 28420 KB Output is correct
9 Correct 16 ms 28364 KB Output is correct
10 Correct 16 ms 28364 KB Output is correct
11 Correct 16 ms 28332 KB Output is correct
12 Correct 15 ms 28364 KB Output is correct
13 Correct 16 ms 28324 KB Output is correct
14 Correct 16 ms 28304 KB Output is correct
15 Correct 17 ms 28296 KB Output is correct
16 Correct 17 ms 28336 KB Output is correct
17 Correct 17 ms 28348 KB Output is correct
18 Correct 18 ms 28364 KB Output is correct
19 Correct 17 ms 28344 KB Output is correct
20 Correct 17 ms 28364 KB Output is correct
21 Correct 16 ms 28400 KB Output is correct
22 Correct 16 ms 28364 KB Output is correct
23 Correct 16 ms 28304 KB Output is correct
24 Correct 47 ms 32784 KB Output is correct
25 Correct 38 ms 32748 KB Output is correct
26 Correct 45 ms 32692 KB Output is correct
27 Correct 15 ms 28236 KB Output is correct
28 Correct 17 ms 28296 KB Output is correct
29 Correct 15 ms 28236 KB Output is correct
30 Correct 16 ms 28236 KB Output is correct
31 Correct 31 ms 28352 KB Output is correct
32 Correct 17 ms 28236 KB Output is correct
33 Correct 16 ms 28296 KB Output is correct
34 Correct 20 ms 28328 KB Output is correct
35 Correct 18 ms 28236 KB Output is correct
36 Correct 18 ms 28328 KB Output is correct
37 Correct 17 ms 28364 KB Output is correct
38 Correct 17 ms 28308 KB Output is correct
39 Correct 16 ms 28364 KB Output is correct
40 Correct 16 ms 28336 KB Output is correct
41 Correct 16 ms 28352 KB Output is correct
42 Correct 19 ms 28340 KB Output is correct
43 Correct 18 ms 28372 KB Output is correct
44 Correct 17 ms 28380 KB Output is correct
45 Correct 16 ms 28364 KB Output is correct
46 Correct 16 ms 28344 KB Output is correct
47 Correct 19 ms 28348 KB Output is correct
48 Correct 67 ms 28340 KB Output is correct
49 Correct 16 ms 28296 KB Output is correct
50 Correct 16 ms 28364 KB Output is correct
51 Correct 17 ms 28344 KB Output is correct
52 Correct 16 ms 28372 KB Output is correct
53 Correct 17 ms 28364 KB Output is correct
54 Correct 17 ms 28348 KB Output is correct
55 Correct 17 ms 28336 KB Output is correct
56 Correct 17 ms 28360 KB Output is correct
57 Correct 17 ms 28364 KB Output is correct
58 Correct 17 ms 28364 KB Output is correct
59 Correct 16 ms 28396 KB Output is correct
60 Correct 17 ms 28288 KB Output is correct
61 Correct 16 ms 28364 KB Output is correct
62 Correct 19 ms 28404 KB Output is correct
63 Correct 16 ms 28364 KB Output is correct
64 Correct 17 ms 28400 KB Output is correct
65 Correct 174 ms 28352 KB Output is correct
66 Correct 76 ms 28476 KB Output is correct
67 Correct 509 ms 28364 KB Output is correct
68 Correct 216 ms 28344 KB Output is correct
69 Correct 433 ms 28364 KB Output is correct
70 Correct 30 ms 28492 KB Output is correct
71 Correct 33 ms 28600 KB Output is correct
72 Correct 31 ms 28480 KB Output is correct
73 Correct 30 ms 28464 KB Output is correct
74 Correct 40 ms 28560 KB Output is correct
75 Correct 25 ms 28492 KB Output is correct
76 Correct 60 ms 31492 KB Output is correct
77 Correct 38 ms 31904 KB Output is correct
78 Correct 47 ms 32476 KB Output is correct
79 Correct 1170 ms 28364 KB Output is correct
80 Correct 1156 ms 28364 KB Output is correct
81 Correct 1254 ms 28368 KB Output is correct
82 Correct 1110 ms 28484 KB Output is correct
83 Correct 1178 ms 28380 KB Output is correct
84 Correct 44 ms 28620 KB Output is correct
85 Correct 43 ms 28664 KB Output is correct
86 Correct 44 ms 28620 KB Output is correct
87 Correct 40 ms 28656 KB Output is correct
88 Correct 42 ms 28672 KB Output is correct
89 Correct 42 ms 28676 KB Output is correct
90 Correct 51 ms 32772 KB Output is correct
91 Correct 55 ms 32856 KB Output is correct
92 Correct 62 ms 32812 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 16 ms 28252 KB Output is correct
2 Correct 15 ms 28272 KB Output is correct
3 Correct 15 ms 28256 KB Output is correct
4 Correct 17 ms 28236 KB Output is correct
5 Correct 17 ms 28320 KB Output is correct
6 Correct 16 ms 28352 KB Output is correct
7 Correct 15 ms 28236 KB Output is correct
8 Correct 16 ms 28420 KB Output is correct
9 Correct 16 ms 28364 KB Output is correct
10 Correct 16 ms 28364 KB Output is correct
11 Correct 16 ms 28332 KB Output is correct
12 Correct 15 ms 28364 KB Output is correct
13 Correct 16 ms 28324 KB Output is correct
14 Correct 16 ms 28304 KB Output is correct
15 Correct 17 ms 28296 KB Output is correct
16 Correct 17 ms 28336 KB Output is correct
17 Correct 17 ms 28348 KB Output is correct
18 Correct 18 ms 28364 KB Output is correct
19 Correct 17 ms 28344 KB Output is correct
20 Correct 17 ms 28364 KB Output is correct
21 Correct 16 ms 28400 KB Output is correct
22 Correct 16 ms 28364 KB Output is correct
23 Correct 16 ms 28304 KB Output is correct
24 Correct 47 ms 32784 KB Output is correct
25 Correct 38 ms 32748 KB Output is correct
26 Correct 45 ms 32692 KB Output is correct
27 Correct 1135 ms 29536 KB Output is correct
28 Correct 1124 ms 29508 KB Output is correct
29 Correct 18 ms 28620 KB Output is correct
30 Correct 19 ms 28660 KB Output is correct
31 Correct 18 ms 28580 KB Output is correct
32 Correct 19 ms 28620 KB Output is correct
33 Execution timed out 1598 ms 29604 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 16 ms 28252 KB Output is correct
2 Correct 15 ms 28272 KB Output is correct
3 Correct 15 ms 28256 KB Output is correct
4 Correct 17 ms 28236 KB Output is correct
5 Correct 17 ms 28320 KB Output is correct
6 Correct 16 ms 28352 KB Output is correct
7 Correct 15 ms 28236 KB Output is correct
8 Correct 16 ms 28420 KB Output is correct
9 Correct 16 ms 28364 KB Output is correct
10 Correct 16 ms 28364 KB Output is correct
11 Correct 16 ms 28332 KB Output is correct
12 Correct 15 ms 28364 KB Output is correct
13 Correct 16 ms 28324 KB Output is correct
14 Correct 16 ms 28304 KB Output is correct
15 Correct 17 ms 28296 KB Output is correct
16 Correct 17 ms 28336 KB Output is correct
17 Correct 17 ms 28348 KB Output is correct
18 Correct 18 ms 28364 KB Output is correct
19 Correct 17 ms 28344 KB Output is correct
20 Correct 17 ms 28364 KB Output is correct
21 Correct 16 ms 28400 KB Output is correct
22 Correct 16 ms 28364 KB Output is correct
23 Correct 16 ms 28304 KB Output is correct
24 Correct 47 ms 32784 KB Output is correct
25 Correct 38 ms 32748 KB Output is correct
26 Correct 45 ms 32692 KB Output is correct
27 Correct 1135 ms 29536 KB Output is correct
28 Correct 1124 ms 29508 KB Output is correct
29 Correct 18 ms 28620 KB Output is correct
30 Correct 19 ms 28660 KB Output is correct
31 Correct 18 ms 28580 KB Output is correct
32 Correct 19 ms 28620 KB Output is correct
33 Execution timed out 1598 ms 29604 KB Time limit exceeded
34 Halted 0 ms 0 KB -