Submission #597394

# Submission time Handle Problem Language Result Execution time Memory
597394 2022-07-16T00:36:22 Z Ozy Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 424872 KB
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;
#define lli int
#define rep(i,a,b) for (int i = (a); i <= (b); i++)
#define repa(i,a,b) for (int i = (a); i >= (b); i--)
#define debug(a) cout << #a << " = " << a << endl
#define debugsl(a) cout << #a << " = " << a << ", "

#define MAX 20000
#define MK 100000

lli n,m,k,res,pos,mejor,dif,a,last;
//valores de 0 a m
map<int, int> lejos[MAX+2];
bitset<MK> tabla[2002];
vector<int> contratistas[MK];
lli top[MAX+2];
//checar memoria

int minimumInstructions(int N, int M, int K, std::vector<int> C,std::vector<int> A, std::vector<std::vector<int>> B) {
    n = N;
    m = M;
    k = K;

    rep(i,0,m-1) {
        rep(j,0,A[i]-1) {
            contratistas[B[i][j]].push_back(i);
        }
    }

    repa(i,n-1,0) {
        top[i] = 0;
        for(auto cont : contratistas[C[i]]) {
            int sigcont = (cont < m - 1) ? cont + 1 : 0;
            int v = (lejos[i+1].count(sigcont)) ? lejos[i+1][sigcont] + 1 : 1;
            lejos[i][cont] = min(m, v);
            top[i] = max(top[i], min(m, v));
        }
    }

    if (top[0] < m) return -1;
    pos = m;
    last = 0;
    res = 1;

    rep(i,1,n-1) {
        if (top[i] == m) last = i;
        if (i == pos) {
            pos = last + m;
            res++;
        }
    }

    if (pos < n) return -1;
    else return res;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3540 KB Output is correct
2 Correct 2 ms 3540 KB Output is correct
3 Correct 2 ms 3540 KB Output is correct
4 Correct 2 ms 3540 KB Output is correct
5 Correct 2 ms 3540 KB Output is correct
6 Correct 2 ms 3540 KB Output is correct
7 Correct 2 ms 3540 KB Output is correct
8 Correct 2 ms 3540 KB Output is correct
9 Correct 2 ms 3604 KB Output is correct
10 Correct 2 ms 3540 KB Output is correct
11 Correct 2 ms 3540 KB Output is correct
12 Correct 2 ms 3540 KB Output is correct
13 Correct 2 ms 3608 KB Output is correct
14 Correct 2 ms 3604 KB Output is correct
15 Correct 2 ms 3668 KB Output is correct
16 Correct 3 ms 3668 KB Output is correct
17 Correct 2 ms 3608 KB Output is correct
18 Correct 2 ms 3668 KB Output is correct
19 Correct 3 ms 3668 KB Output is correct
20 Correct 3 ms 3612 KB Output is correct
21 Correct 3 ms 3668 KB Output is correct
22 Correct 22 ms 7652 KB Output is correct
23 Correct 18 ms 7632 KB Output is correct
24 Correct 25 ms 7668 KB Output is correct
25 Correct 5 ms 4692 KB Output is correct
26 Correct 5 ms 4692 KB Output is correct
27 Correct 6 ms 4692 KB Output is correct
28 Correct 5 ms 4692 KB Output is correct
29 Correct 6 ms 4692 KB Output is correct
30 Correct 6 ms 4692 KB Output is correct
31 Correct 11 ms 5788 KB Output is correct
32 Correct 13 ms 5716 KB Output is correct
33 Correct 9 ms 5816 KB Output is correct
34 Correct 9 ms 5716 KB Output is correct
35 Correct 10 ms 5716 KB Output is correct
36 Correct 10 ms 5828 KB Output is correct
37 Correct 25 ms 8904 KB Output is correct
38 Correct 32 ms 8864 KB Output is correct
39 Correct 32 ms 8908 KB Output is correct
40 Runtime error 17 ms 8584 KB Execution killed with signal 11
41 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3540 KB Output is correct
2 Correct 2 ms 3540 KB Output is correct
3 Correct 2 ms 3540 KB Output is correct
4 Correct 2 ms 3540 KB Output is correct
5 Correct 2 ms 3540 KB Output is correct
6 Correct 2 ms 3540 KB Output is correct
7 Correct 2 ms 3540 KB Output is correct
8 Correct 2 ms 3540 KB Output is correct
9 Correct 2 ms 3604 KB Output is correct
10 Correct 2 ms 3540 KB Output is correct
11 Correct 2 ms 3540 KB Output is correct
12 Correct 2 ms 3540 KB Output is correct
13 Correct 2 ms 3608 KB Output is correct
14 Correct 2 ms 3604 KB Output is correct
15 Correct 2 ms 3668 KB Output is correct
16 Correct 3 ms 3668 KB Output is correct
17 Correct 2 ms 3608 KB Output is correct
18 Correct 2 ms 3668 KB Output is correct
19 Correct 3 ms 3668 KB Output is correct
20 Correct 3 ms 3612 KB Output is correct
21 Correct 3 ms 3668 KB Output is correct
22 Correct 2 ms 3604 KB Output is correct
23 Correct 2 ms 3540 KB Output is correct
24 Correct 2 ms 3540 KB Output is correct
25 Correct 2 ms 3540 KB Output is correct
26 Correct 2 ms 3600 KB Output is correct
27 Correct 2 ms 3540 KB Output is correct
28 Correct 3 ms 3924 KB Output is correct
29 Correct 2 ms 3796 KB Output is correct
30 Correct 3 ms 3796 KB Output is correct
31 Correct 2 ms 3728 KB Output is correct
32 Correct 3 ms 3796 KB Output is correct
33 Correct 2 ms 3608 KB Output is correct
34 Correct 2 ms 3540 KB Output is correct
35 Correct 2 ms 3540 KB Output is correct
36 Correct 2 ms 3540 KB Output is correct
37 Correct 2 ms 3540 KB Output is correct
38 Correct 2 ms 3608 KB Output is correct
39 Correct 2 ms 3540 KB Output is correct
40 Correct 2 ms 3612 KB Output is correct
41 Correct 2 ms 3540 KB Output is correct
42 Correct 3 ms 3540 KB Output is correct
43 Correct 2 ms 3540 KB Output is correct
44 Correct 2 ms 3540 KB Output is correct
45 Correct 6 ms 4308 KB Output is correct
46 Correct 4 ms 4052 KB Output is correct
47 Correct 4 ms 3924 KB Output is correct
48 Correct 3 ms 3924 KB Output is correct
49 Correct 3 ms 3924 KB Output is correct
50 Correct 2 ms 3668 KB Output is correct
51 Correct 2 ms 3668 KB Output is correct
52 Correct 2 ms 3668 KB Output is correct
53 Correct 2 ms 3668 KB Output is correct
54 Correct 3 ms 3668 KB Output is correct
55 Correct 2 ms 3668 KB Output is correct
56 Correct 2 ms 3596 KB Output is correct
57 Correct 2 ms 3668 KB Output is correct
58 Correct 2 ms 3668 KB Output is correct
59 Correct 2 ms 3604 KB Output is correct
60 Correct 4 ms 3668 KB Output is correct
61 Correct 3 ms 3668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3604 KB Output is correct
2 Correct 2 ms 3540 KB Output is correct
3 Correct 2 ms 3540 KB Output is correct
4 Correct 2 ms 3540 KB Output is correct
5 Correct 2 ms 3540 KB Output is correct
6 Correct 2 ms 3540 KB Output is correct
7 Correct 2 ms 3540 KB Output is correct
8 Correct 2 ms 3540 KB Output is correct
9 Correct 2 ms 3540 KB Output is correct
10 Correct 2 ms 3540 KB Output is correct
11 Correct 2 ms 3604 KB Output is correct
12 Correct 2 ms 3540 KB Output is correct
13 Correct 2 ms 3540 KB Output is correct
14 Correct 2 ms 3540 KB Output is correct
15 Correct 2 ms 3608 KB Output is correct
16 Correct 2 ms 3604 KB Output is correct
17 Correct 2 ms 3668 KB Output is correct
18 Correct 3 ms 3668 KB Output is correct
19 Correct 2 ms 3608 KB Output is correct
20 Correct 2 ms 3668 KB Output is correct
21 Correct 3 ms 3668 KB Output is correct
22 Correct 3 ms 3612 KB Output is correct
23 Correct 3 ms 3668 KB Output is correct
24 Correct 22 ms 7652 KB Output is correct
25 Correct 18 ms 7632 KB Output is correct
26 Correct 25 ms 7668 KB Output is correct
27 Correct 2 ms 3540 KB Output is correct
28 Correct 2 ms 3540 KB Output is correct
29 Correct 2 ms 3600 KB Output is correct
30 Correct 2 ms 3540 KB Output is correct
31 Correct 3 ms 3924 KB Output is correct
32 Correct 2 ms 3796 KB Output is correct
33 Correct 3 ms 3796 KB Output is correct
34 Correct 2 ms 3728 KB Output is correct
35 Correct 3 ms 3796 KB Output is correct
36 Correct 2 ms 3608 KB Output is correct
37 Correct 2 ms 3540 KB Output is correct
38 Correct 2 ms 3540 KB Output is correct
39 Correct 2 ms 3540 KB Output is correct
40 Correct 2 ms 3540 KB Output is correct
41 Correct 2 ms 3608 KB Output is correct
42 Correct 2 ms 3540 KB Output is correct
43 Correct 2 ms 3612 KB Output is correct
44 Correct 2 ms 3540 KB Output is correct
45 Correct 3 ms 3540 KB Output is correct
46 Correct 2 ms 3540 KB Output is correct
47 Correct 2 ms 3540 KB Output is correct
48 Correct 6 ms 4308 KB Output is correct
49 Correct 4 ms 4052 KB Output is correct
50 Correct 4 ms 3924 KB Output is correct
51 Correct 3 ms 3924 KB Output is correct
52 Correct 3 ms 3924 KB Output is correct
53 Correct 2 ms 3668 KB Output is correct
54 Correct 2 ms 3668 KB Output is correct
55 Correct 2 ms 3668 KB Output is correct
56 Correct 2 ms 3668 KB Output is correct
57 Correct 3 ms 3668 KB Output is correct
58 Correct 2 ms 3668 KB Output is correct
59 Correct 2 ms 3596 KB Output is correct
60 Correct 2 ms 3668 KB Output is correct
61 Correct 2 ms 3668 KB Output is correct
62 Correct 2 ms 3604 KB Output is correct
63 Correct 4 ms 3668 KB Output is correct
64 Correct 3 ms 3668 KB Output is correct
65 Correct 14 ms 5716 KB Output is correct
66 Correct 7 ms 4500 KB Output is correct
67 Correct 11 ms 6424 KB Output is correct
68 Correct 8 ms 5284 KB Output is correct
69 Correct 10 ms 6040 KB Output is correct
70 Correct 4 ms 4256 KB Output is correct
71 Correct 6 ms 4276 KB Output is correct
72 Correct 4 ms 4308 KB Output is correct
73 Correct 3 ms 3924 KB Output is correct
74 Correct 5 ms 4308 KB Output is correct
75 Correct 4 ms 4164 KB Output is correct
76 Correct 18 ms 6324 KB Output is correct
77 Correct 18 ms 6728 KB Output is correct
78 Correct 23 ms 7172 KB Output is correct
79 Correct 19 ms 8240 KB Output is correct
80 Correct 18 ms 8212 KB Output is correct
81 Correct 20 ms 8276 KB Output is correct
82 Correct 21 ms 8224 KB Output is correct
83 Correct 21 ms 8208 KB Output is correct
84 Correct 6 ms 4436 KB Output is correct
85 Correct 6 ms 4520 KB Output is correct
86 Correct 5 ms 4436 KB Output is correct
87 Correct 5 ms 4436 KB Output is correct
88 Correct 5 ms 4460 KB Output is correct
89 Correct 5 ms 4508 KB Output is correct
90 Correct 27 ms 7376 KB Output is correct
91 Correct 27 ms 7432 KB Output is correct
92 Correct 27 ms 7432 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3604 KB Output is correct
2 Correct 2 ms 3540 KB Output is correct
3 Correct 2 ms 3540 KB Output is correct
4 Correct 2 ms 3540 KB Output is correct
5 Correct 2 ms 3540 KB Output is correct
6 Correct 2 ms 3540 KB Output is correct
7 Correct 2 ms 3540 KB Output is correct
8 Correct 2 ms 3540 KB Output is correct
9 Correct 2 ms 3540 KB Output is correct
10 Correct 2 ms 3540 KB Output is correct
11 Correct 2 ms 3604 KB Output is correct
12 Correct 2 ms 3540 KB Output is correct
13 Correct 2 ms 3540 KB Output is correct
14 Correct 2 ms 3540 KB Output is correct
15 Correct 2 ms 3608 KB Output is correct
16 Correct 2 ms 3604 KB Output is correct
17 Correct 2 ms 3668 KB Output is correct
18 Correct 3 ms 3668 KB Output is correct
19 Correct 2 ms 3608 KB Output is correct
20 Correct 2 ms 3668 KB Output is correct
21 Correct 3 ms 3668 KB Output is correct
22 Correct 3 ms 3612 KB Output is correct
23 Correct 3 ms 3668 KB Output is correct
24 Correct 22 ms 7652 KB Output is correct
25 Correct 18 ms 7632 KB Output is correct
26 Correct 25 ms 7668 KB Output is correct
27 Correct 5 ms 4692 KB Output is correct
28 Correct 5 ms 4692 KB Output is correct
29 Correct 6 ms 4692 KB Output is correct
30 Correct 5 ms 4692 KB Output is correct
31 Correct 6 ms 4692 KB Output is correct
32 Correct 6 ms 4692 KB Output is correct
33 Correct 11 ms 5788 KB Output is correct
34 Correct 13 ms 5716 KB Output is correct
35 Correct 9 ms 5816 KB Output is correct
36 Correct 9 ms 5716 KB Output is correct
37 Correct 10 ms 5716 KB Output is correct
38 Correct 10 ms 5828 KB Output is correct
39 Correct 25 ms 8904 KB Output is correct
40 Correct 32 ms 8864 KB Output is correct
41 Correct 32 ms 8908 KB Output is correct
42 Correct 2 ms 3540 KB Output is correct
43 Correct 2 ms 3540 KB Output is correct
44 Correct 2 ms 3600 KB Output is correct
45 Correct 2 ms 3540 KB Output is correct
46 Correct 3 ms 3924 KB Output is correct
47 Correct 2 ms 3796 KB Output is correct
48 Correct 3 ms 3796 KB Output is correct
49 Correct 2 ms 3728 KB Output is correct
50 Correct 3 ms 3796 KB Output is correct
51 Correct 2 ms 3608 KB Output is correct
52 Correct 2 ms 3540 KB Output is correct
53 Correct 2 ms 3540 KB Output is correct
54 Correct 2 ms 3540 KB Output is correct
55 Correct 2 ms 3540 KB Output is correct
56 Correct 2 ms 3608 KB Output is correct
57 Correct 2 ms 3540 KB Output is correct
58 Correct 2 ms 3612 KB Output is correct
59 Correct 2 ms 3540 KB Output is correct
60 Correct 3 ms 3540 KB Output is correct
61 Correct 2 ms 3540 KB Output is correct
62 Correct 2 ms 3540 KB Output is correct
63 Correct 6 ms 4308 KB Output is correct
64 Correct 4 ms 4052 KB Output is correct
65 Correct 4 ms 3924 KB Output is correct
66 Correct 3 ms 3924 KB Output is correct
67 Correct 3 ms 3924 KB Output is correct
68 Correct 2 ms 3668 KB Output is correct
69 Correct 2 ms 3668 KB Output is correct
70 Correct 2 ms 3668 KB Output is correct
71 Correct 2 ms 3668 KB Output is correct
72 Correct 3 ms 3668 KB Output is correct
73 Correct 2 ms 3668 KB Output is correct
74 Correct 2 ms 3596 KB Output is correct
75 Correct 2 ms 3668 KB Output is correct
76 Correct 2 ms 3668 KB Output is correct
77 Correct 2 ms 3604 KB Output is correct
78 Correct 4 ms 3668 KB Output is correct
79 Correct 3 ms 3668 KB Output is correct
80 Correct 14 ms 5716 KB Output is correct
81 Correct 7 ms 4500 KB Output is correct
82 Correct 11 ms 6424 KB Output is correct
83 Correct 8 ms 5284 KB Output is correct
84 Correct 10 ms 6040 KB Output is correct
85 Correct 4 ms 4256 KB Output is correct
86 Correct 6 ms 4276 KB Output is correct
87 Correct 4 ms 4308 KB Output is correct
88 Correct 3 ms 3924 KB Output is correct
89 Correct 5 ms 4308 KB Output is correct
90 Correct 4 ms 4164 KB Output is correct
91 Correct 18 ms 6324 KB Output is correct
92 Correct 18 ms 6728 KB Output is correct
93 Correct 23 ms 7172 KB Output is correct
94 Correct 19 ms 8240 KB Output is correct
95 Correct 18 ms 8212 KB Output is correct
96 Correct 20 ms 8276 KB Output is correct
97 Correct 21 ms 8224 KB Output is correct
98 Correct 21 ms 8208 KB Output is correct
99 Correct 6 ms 4436 KB Output is correct
100 Correct 6 ms 4520 KB Output is correct
101 Correct 5 ms 4436 KB Output is correct
102 Correct 5 ms 4436 KB Output is correct
103 Correct 5 ms 4460 KB Output is correct
104 Correct 5 ms 4508 KB Output is correct
105 Correct 27 ms 7376 KB Output is correct
106 Correct 27 ms 7432 KB Output is correct
107 Correct 27 ms 7432 KB Output is correct
108 Correct 6 ms 5664 KB Output is correct
109 Execution timed out 1546 ms 424872 KB Time limit exceeded
110 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3604 KB Output is correct
2 Correct 2 ms 3540 KB Output is correct
3 Correct 2 ms 3540 KB Output is correct
4 Correct 2 ms 3540 KB Output is correct
5 Correct 2 ms 3540 KB Output is correct
6 Correct 2 ms 3540 KB Output is correct
7 Correct 2 ms 3540 KB Output is correct
8 Correct 2 ms 3540 KB Output is correct
9 Correct 2 ms 3540 KB Output is correct
10 Correct 2 ms 3540 KB Output is correct
11 Correct 2 ms 3604 KB Output is correct
12 Correct 2 ms 3540 KB Output is correct
13 Correct 2 ms 3540 KB Output is correct
14 Correct 2 ms 3540 KB Output is correct
15 Correct 2 ms 3608 KB Output is correct
16 Correct 2 ms 3604 KB Output is correct
17 Correct 2 ms 3668 KB Output is correct
18 Correct 3 ms 3668 KB Output is correct
19 Correct 2 ms 3608 KB Output is correct
20 Correct 2 ms 3668 KB Output is correct
21 Correct 3 ms 3668 KB Output is correct
22 Correct 3 ms 3612 KB Output is correct
23 Correct 3 ms 3668 KB Output is correct
24 Correct 22 ms 7652 KB Output is correct
25 Correct 18 ms 7632 KB Output is correct
26 Correct 25 ms 7668 KB Output is correct
27 Correct 5 ms 4692 KB Output is correct
28 Correct 5 ms 4692 KB Output is correct
29 Correct 6 ms 4692 KB Output is correct
30 Correct 5 ms 4692 KB Output is correct
31 Correct 6 ms 4692 KB Output is correct
32 Correct 6 ms 4692 KB Output is correct
33 Correct 11 ms 5788 KB Output is correct
34 Correct 13 ms 5716 KB Output is correct
35 Correct 9 ms 5816 KB Output is correct
36 Correct 9 ms 5716 KB Output is correct
37 Correct 10 ms 5716 KB Output is correct
38 Correct 10 ms 5828 KB Output is correct
39 Correct 25 ms 8904 KB Output is correct
40 Correct 32 ms 8864 KB Output is correct
41 Correct 32 ms 8908 KB Output is correct
42 Runtime error 17 ms 8584 KB Execution killed with signal 11
43 Halted 0 ms 0 KB -