Submission #1054447

# Submission time Handle Problem Language Result Execution time Memory
1054447 2024-08-12T09:57:52 Z alexander707070 Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 43608 KB
#include<bits/stdc++.h>
#include "paint.h"

#define MAXN 100007
using namespace std;

int n,m,k,ans;
int c[MAXN];
vector<int> cols[MAXN];

bool can[20007][2007];
int to[2][2007];
int best[MAXN],pref[MAXN];

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

    for(int i=1;i<=n;i++){
        c[i]=C[i-1];
    }

    for(int i=1;i<=m;i++){
        cols[i]=B[i-1];
    }

    for(int i=1;i<=n;i++){
        for(int f=1;f<=m;f++){
            for(int s:cols[f]){
                if(s==c[i])can[i][f]=true;
            }
        }
    }

    for(int i=n;i>=1;i--){
        for(int f=1;f<=m;f++){
            if(!can[i][f])to[i%2][f]=0;
            else{
                if(f<m)to[i%2][f]=to[1-i%2][f+1]+1;
                else to[i%2][f]=to[1-i%2][1]+1;
            }

            if(to[i%2][f]>=m)best[i]=max(best[i],i+m);
        }
    }

    for(int i=1;i<=n;i++){
        pref[i]=max(pref[i-1],best[i]);
    }

    int pos=1;
    while(pos<=n){
        if(pref[pos]==pos)return -1;

        pos=pref[pos];
        ans++;
    }

    return ans;
}

/*
int main(){
    //cout<<minimumInstructions(8, 3, 5, {3, 3, 1, 3, 4, 4, 2, 2}, {3, 2, 2}, {{0, 1, 2}, {2, 3}, {3, 4}});
    cout<<minimumInstructions(5, 4, 4, {1, 0, 1, 2, 2}, {2, 1, 1, 1}, {{0, 1}, {1}, {2}, {3}});


    return 0;
}
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 5720 KB Output is correct
2 Correct 1 ms 5724 KB Output is correct
3 Correct 1 ms 5760 KB Output is correct
4 Correct 1 ms 5540 KB Output is correct
5 Correct 1 ms 5724 KB Output is correct
6 Correct 1 ms 5724 KB Output is correct
7 Correct 1 ms 5724 KB Output is correct
8 Correct 1 ms 5724 KB Output is correct
9 Correct 1 ms 5724 KB Output is correct
10 Correct 1 ms 5724 KB Output is correct
11 Correct 1 ms 5724 KB Output is correct
12 Correct 1 ms 5724 KB Output is correct
13 Correct 1 ms 5724 KB Output is correct
14 Correct 2 ms 5724 KB Output is correct
15 Correct 1 ms 5788 KB Output is correct
16 Correct 1 ms 5724 KB Output is correct
17 Correct 1 ms 5724 KB Output is correct
18 Correct 1 ms 5724 KB Output is correct
19 Correct 1 ms 5724 KB Output is correct
20 Correct 2 ms 5780 KB Output is correct
21 Correct 1 ms 5772 KB Output is correct
22 Correct 48 ms 7516 KB Output is correct
23 Correct 48 ms 7516 KB Output is correct
24 Correct 50 ms 7516 KB Output is correct
25 Correct 5 ms 42844 KB Output is correct
26 Correct 5 ms 42844 KB Output is correct
27 Correct 6 ms 42844 KB Output is correct
28 Correct 5 ms 42844 KB Output is correct
29 Correct 5 ms 42844 KB Output is correct
30 Correct 5 ms 42960 KB Output is correct
31 Correct 356 ms 43468 KB Output is correct
32 Correct 350 ms 43600 KB Output is correct
33 Correct 354 ms 43476 KB Output is correct
34 Correct 378 ms 43608 KB Output is correct
35 Correct 358 ms 43480 KB Output is correct
36 Correct 360 ms 43604 KB Output is correct
37 Execution timed out 1583 ms 40828 KB Time limit exceeded
38 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 5720 KB Output is correct
2 Correct 1 ms 5724 KB Output is correct
3 Correct 1 ms 5760 KB Output is correct
4 Correct 1 ms 5540 KB Output is correct
5 Correct 1 ms 5724 KB Output is correct
6 Correct 1 ms 5724 KB Output is correct
7 Correct 1 ms 5724 KB Output is correct
8 Correct 1 ms 5724 KB Output is correct
9 Correct 1 ms 5724 KB Output is correct
10 Correct 1 ms 5724 KB Output is correct
11 Correct 1 ms 5724 KB Output is correct
12 Correct 1 ms 5724 KB Output is correct
13 Correct 1 ms 5724 KB Output is correct
14 Correct 2 ms 5724 KB Output is correct
15 Correct 1 ms 5788 KB Output is correct
16 Correct 1 ms 5724 KB Output is correct
17 Correct 1 ms 5724 KB Output is correct
18 Correct 1 ms 5724 KB Output is correct
19 Correct 1 ms 5724 KB Output is correct
20 Correct 2 ms 5780 KB Output is correct
21 Correct 1 ms 5772 KB Output is correct
22 Correct 1 ms 5724 KB Output is correct
23 Correct 1 ms 5724 KB Output is correct
24 Correct 1 ms 5756 KB Output is correct
25 Correct 1 ms 5724 KB Output is correct
26 Correct 1 ms 5724 KB Output is correct
27 Correct 1 ms 5724 KB Output is correct
28 Correct 1 ms 5724 KB Output is correct
29 Correct 1 ms 5724 KB Output is correct
30 Correct 1 ms 5724 KB Output is correct
31 Correct 1 ms 5724 KB Output is correct
32 Correct 1 ms 5764 KB Output is correct
33 Correct 1 ms 5724 KB Output is correct
34 Correct 1 ms 5720 KB Output is correct
35 Correct 1 ms 5724 KB Output is correct
36 Correct 1 ms 5724 KB Output is correct
37 Correct 1 ms 5724 KB Output is correct
38 Correct 1 ms 5724 KB Output is correct
39 Correct 1 ms 5724 KB Output is correct
40 Correct 1 ms 5724 KB Output is correct
41 Correct 1 ms 5724 KB Output is correct
42 Correct 2 ms 5724 KB Output is correct
43 Correct 1 ms 5724 KB Output is correct
44 Correct 1 ms 5724 KB Output is correct
45 Correct 1 ms 5724 KB Output is correct
46 Correct 1 ms 5720 KB Output is correct
47 Correct 1 ms 5724 KB Output is correct
48 Correct 1 ms 5720 KB Output is correct
49 Correct 1 ms 5724 KB Output is correct
50 Correct 1 ms 5724 KB Output is correct
51 Correct 1 ms 5724 KB Output is correct
52 Correct 1 ms 5724 KB Output is correct
53 Correct 2 ms 5808 KB Output is correct
54 Correct 1 ms 5724 KB Output is correct
55 Correct 1 ms 5724 KB Output is correct
56 Correct 2 ms 5720 KB Output is correct
57 Correct 1 ms 5724 KB Output is correct
58 Correct 1 ms 5724 KB Output is correct
59 Correct 2 ms 5724 KB Output is correct
60 Correct 1 ms 5724 KB Output is correct
61 Correct 1 ms 5724 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 5724 KB Output is correct
2 Correct 1 ms 5724 KB Output is correct
3 Correct 1 ms 5720 KB Output is correct
4 Correct 1 ms 5724 KB Output is correct
5 Correct 1 ms 5760 KB Output is correct
6 Correct 1 ms 5540 KB Output is correct
7 Correct 1 ms 5724 KB Output is correct
8 Correct 1 ms 5724 KB Output is correct
9 Correct 1 ms 5724 KB Output is correct
10 Correct 1 ms 5724 KB Output is correct
11 Correct 1 ms 5724 KB Output is correct
12 Correct 1 ms 5724 KB Output is correct
13 Correct 1 ms 5724 KB Output is correct
14 Correct 1 ms 5724 KB Output is correct
15 Correct 1 ms 5724 KB Output is correct
16 Correct 2 ms 5724 KB Output is correct
17 Correct 1 ms 5788 KB Output is correct
18 Correct 1 ms 5724 KB Output is correct
19 Correct 1 ms 5724 KB Output is correct
20 Correct 1 ms 5724 KB Output is correct
21 Correct 1 ms 5724 KB Output is correct
22 Correct 2 ms 5780 KB Output is correct
23 Correct 1 ms 5772 KB Output is correct
24 Correct 48 ms 7516 KB Output is correct
25 Correct 48 ms 7516 KB Output is correct
26 Correct 50 ms 7516 KB Output is correct
27 Correct 1 ms 5756 KB Output is correct
28 Correct 1 ms 5724 KB Output is correct
29 Correct 1 ms 5724 KB Output is correct
30 Correct 1 ms 5724 KB Output is correct
31 Correct 1 ms 5724 KB Output is correct
32 Correct 1 ms 5724 KB Output is correct
33 Correct 1 ms 5724 KB Output is correct
34 Correct 1 ms 5724 KB Output is correct
35 Correct 1 ms 5764 KB Output is correct
36 Correct 1 ms 5724 KB Output is correct
37 Correct 1 ms 5720 KB Output is correct
38 Correct 1 ms 5724 KB Output is correct
39 Correct 1 ms 5724 KB Output is correct
40 Correct 1 ms 5724 KB Output is correct
41 Correct 1 ms 5724 KB Output is correct
42 Correct 1 ms 5724 KB Output is correct
43 Correct 1 ms 5724 KB Output is correct
44 Correct 1 ms 5724 KB Output is correct
45 Correct 2 ms 5724 KB Output is correct
46 Correct 1 ms 5724 KB Output is correct
47 Correct 1 ms 5724 KB Output is correct
48 Correct 1 ms 5724 KB Output is correct
49 Correct 1 ms 5720 KB Output is correct
50 Correct 1 ms 5724 KB Output is correct
51 Correct 1 ms 5720 KB Output is correct
52 Correct 1 ms 5724 KB Output is correct
53 Correct 1 ms 5724 KB Output is correct
54 Correct 1 ms 5724 KB Output is correct
55 Correct 1 ms 5724 KB Output is correct
56 Correct 2 ms 5808 KB Output is correct
57 Correct 1 ms 5724 KB Output is correct
58 Correct 1 ms 5724 KB Output is correct
59 Correct 2 ms 5720 KB Output is correct
60 Correct 1 ms 5724 KB Output is correct
61 Correct 1 ms 5724 KB Output is correct
62 Correct 2 ms 5724 KB Output is correct
63 Correct 1 ms 5724 KB Output is correct
64 Correct 1 ms 5724 KB Output is correct
65 Correct 1 ms 5724 KB Output is correct
66 Correct 1 ms 5724 KB Output is correct
67 Correct 1 ms 5724 KB Output is correct
68 Correct 1 ms 5724 KB Output is correct
69 Correct 1 ms 5724 KB Output is correct
70 Correct 6 ms 5980 KB Output is correct
71 Correct 6 ms 5848 KB Output is correct
72 Correct 6 ms 5720 KB Output is correct
73 Correct 3 ms 5888 KB Output is correct
74 Correct 5 ms 5724 KB Output is correct
75 Correct 4 ms 5940 KB Output is correct
76 Correct 34 ms 7512 KB Output is correct
77 Correct 42 ms 7772 KB Output is correct
78 Correct 49 ms 8284 KB Output is correct
79 Correct 1 ms 5720 KB Output is correct
80 Correct 1 ms 5724 KB Output is correct
81 Correct 1 ms 5724 KB Output is correct
82 Correct 1 ms 5764 KB Output is correct
83 Correct 1 ms 5724 KB Output is correct
84 Correct 8 ms 5976 KB Output is correct
85 Correct 8 ms 5868 KB Output is correct
86 Correct 9 ms 5976 KB Output is correct
87 Correct 9 ms 5980 KB Output is correct
88 Correct 8 ms 5980 KB Output is correct
89 Correct 8 ms 6032 KB Output is correct
90 Correct 74 ms 8284 KB Output is correct
91 Correct 74 ms 8284 KB Output is correct
92 Correct 83 ms 8284 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 5724 KB Output is correct
2 Correct 1 ms 5724 KB Output is correct
3 Correct 1 ms 5720 KB Output is correct
4 Correct 1 ms 5724 KB Output is correct
5 Correct 1 ms 5760 KB Output is correct
6 Correct 1 ms 5540 KB Output is correct
7 Correct 1 ms 5724 KB Output is correct
8 Correct 1 ms 5724 KB Output is correct
9 Correct 1 ms 5724 KB Output is correct
10 Correct 1 ms 5724 KB Output is correct
11 Correct 1 ms 5724 KB Output is correct
12 Correct 1 ms 5724 KB Output is correct
13 Correct 1 ms 5724 KB Output is correct
14 Correct 1 ms 5724 KB Output is correct
15 Correct 1 ms 5724 KB Output is correct
16 Correct 2 ms 5724 KB Output is correct
17 Correct 1 ms 5788 KB Output is correct
18 Correct 1 ms 5724 KB Output is correct
19 Correct 1 ms 5724 KB Output is correct
20 Correct 1 ms 5724 KB Output is correct
21 Correct 1 ms 5724 KB Output is correct
22 Correct 2 ms 5780 KB Output is correct
23 Correct 1 ms 5772 KB Output is correct
24 Correct 48 ms 7516 KB Output is correct
25 Correct 48 ms 7516 KB Output is correct
26 Correct 50 ms 7516 KB Output is correct
27 Correct 5 ms 42844 KB Output is correct
28 Correct 5 ms 42844 KB Output is correct
29 Correct 6 ms 42844 KB Output is correct
30 Correct 5 ms 42844 KB Output is correct
31 Correct 5 ms 42844 KB Output is correct
32 Correct 5 ms 42960 KB Output is correct
33 Correct 356 ms 43468 KB Output is correct
34 Correct 350 ms 43600 KB Output is correct
35 Correct 354 ms 43476 KB Output is correct
36 Correct 378 ms 43608 KB Output is correct
37 Correct 358 ms 43480 KB Output is correct
38 Correct 360 ms 43604 KB Output is correct
39 Execution timed out 1583 ms 40828 KB Time limit exceeded
40 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 5724 KB Output is correct
2 Correct 1 ms 5724 KB Output is correct
3 Correct 1 ms 5720 KB Output is correct
4 Correct 1 ms 5724 KB Output is correct
5 Correct 1 ms 5760 KB Output is correct
6 Correct 1 ms 5540 KB Output is correct
7 Correct 1 ms 5724 KB Output is correct
8 Correct 1 ms 5724 KB Output is correct
9 Correct 1 ms 5724 KB Output is correct
10 Correct 1 ms 5724 KB Output is correct
11 Correct 1 ms 5724 KB Output is correct
12 Correct 1 ms 5724 KB Output is correct
13 Correct 1 ms 5724 KB Output is correct
14 Correct 1 ms 5724 KB Output is correct
15 Correct 1 ms 5724 KB Output is correct
16 Correct 2 ms 5724 KB Output is correct
17 Correct 1 ms 5788 KB Output is correct
18 Correct 1 ms 5724 KB Output is correct
19 Correct 1 ms 5724 KB Output is correct
20 Correct 1 ms 5724 KB Output is correct
21 Correct 1 ms 5724 KB Output is correct
22 Correct 2 ms 5780 KB Output is correct
23 Correct 1 ms 5772 KB Output is correct
24 Correct 48 ms 7516 KB Output is correct
25 Correct 48 ms 7516 KB Output is correct
26 Correct 50 ms 7516 KB Output is correct
27 Correct 5 ms 42844 KB Output is correct
28 Correct 5 ms 42844 KB Output is correct
29 Correct 6 ms 42844 KB Output is correct
30 Correct 5 ms 42844 KB Output is correct
31 Correct 5 ms 42844 KB Output is correct
32 Correct 5 ms 42960 KB Output is correct
33 Correct 356 ms 43468 KB Output is correct
34 Correct 350 ms 43600 KB Output is correct
35 Correct 354 ms 43476 KB Output is correct
36 Correct 378 ms 43608 KB Output is correct
37 Correct 358 ms 43480 KB Output is correct
38 Correct 360 ms 43604 KB Output is correct
39 Execution timed out 1583 ms 40828 KB Time limit exceeded
40 Halted 0 ms 0 KB -