Submission #898296

# Submission time Handle Problem Language Result Execution time Memory
898296 2024-01-04T12:56:57 Z irmuun Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 25356 KB
#include<bits/stdc++.h>
//#include "paint.h"
 
using namespace std;
 
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()

int minimumInstructions(int n,int m,int k,vector<int>C,vector<int>A,vector<vector<int>>B){
    vector<vector<bool>>can(m,vector<bool>(k,false));
    for(int i=0;i<m;i++){
        for(int j=0;j<A[i];j++){
            can[i][B[i][j]]=true;
        }
    }
    vector<bool>canStart(n,0);
    int cur;
    for(int i=0;i<=n-m;i++){
        bool flag=false;
        for(int s=0;s<m;s++){
            bool now=true;
            for(int y=0;y<m;y++){
                now&=(can[(s+y)%m][C[i+y]]);
            }
            flag|=now;
        }
        if(flag){
            canStart[i]=true;
        }
    }
    int ans=0;
    bool ok=true;
    if(!canStart[0]) return -1;
    ans++;
    int r=m-1,nxt=0;
    for(int i=1;i<n;i++){
        if(canStart[i]){
            nxt=i;
        }
        if(i>r){
            r=nxt+m-1;
            if(i>r) return -1;
            ans++;
        }
    }
    return ans;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:21:9: warning: unused variable 'cur' [-Wunused-variable]
   21 |     int cur;
      |         ^~~
paint.cpp:36:10: warning: unused variable 'ok' [-Wunused-variable]
   36 |     bool ok=true;
      |          ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 57 ms 2908 KB Output is correct
14 Correct 56 ms 2904 KB Output is correct
15 Correct 53 ms 2908 KB Output is correct
16 Correct 55 ms 2904 KB Output is correct
17 Correct 55 ms 2908 KB Output is correct
18 Correct 54 ms 2904 KB Output is correct
19 Correct 54 ms 2652 KB Output is correct
20 Correct 53 ms 2872 KB Output is correct
21 Correct 55 ms 2904 KB Output is correct
22 Correct 61 ms 3672 KB Output is correct
23 Correct 62 ms 3828 KB Output is correct
24 Correct 61 ms 3676 KB Output is correct
25 Correct 2 ms 348 KB Output is correct
26 Correct 2 ms 348 KB Output is correct
27 Correct 2 ms 512 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 3 ms 348 KB Output is correct
30 Correct 4 ms 348 KB Output is correct
31 Execution timed out 1593 ms 25356 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 1 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 57 ms 2908 KB Output is correct
14 Correct 56 ms 2904 KB Output is correct
15 Correct 53 ms 2908 KB Output is correct
16 Correct 55 ms 2904 KB Output is correct
17 Correct 55 ms 2908 KB Output is correct
18 Correct 54 ms 2904 KB Output is correct
19 Correct 54 ms 2652 KB Output is correct
20 Correct 53 ms 2872 KB Output is correct
21 Correct 55 ms 2904 KB Output is correct
22 Correct 0 ms 600 KB Output is correct
23 Correct 1 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 436 KB Output is correct
26 Correct 1 ms 344 KB Output is correct
27 Correct 1 ms 344 KB Output is correct
28 Correct 1 ms 348 KB Output is correct
29 Correct 1 ms 348 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 3 ms 348 KB Output is correct
33 Correct 29 ms 1884 KB Output is correct
34 Correct 33 ms 1744 KB Output is correct
35 Correct 13 ms 1116 KB Output is correct
36 Correct 25 ms 2140 KB Output is correct
37 Correct 23 ms 2140 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 19 ms 1988 KB Output is correct
41 Correct 18 ms 348 KB Output is correct
42 Correct 11 ms 1372 KB Output is correct
43 Correct 4 ms 860 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 2 ms 348 KB Output is correct
46 Correct 4 ms 436 KB Output is correct
47 Correct 5 ms 348 KB Output is correct
48 Correct 7 ms 348 KB Output is correct
49 Correct 8 ms 348 KB Output is correct
50 Correct 55 ms 2912 KB Output is correct
51 Correct 55 ms 2908 KB Output is correct
52 Correct 55 ms 2904 KB Output is correct
53 Correct 57 ms 2908 KB Output is correct
54 Correct 55 ms 2908 KB Output is correct
55 Correct 54 ms 2904 KB Output is correct
56 Correct 57 ms 2908 KB Output is correct
57 Correct 52 ms 348 KB Output is correct
58 Correct 54 ms 2652 KB Output is correct
59 Correct 52 ms 468 KB Output is correct
60 Correct 54 ms 2908 KB Output is correct
61 Correct 52 ms 344 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 57 ms 2908 KB Output is correct
16 Correct 56 ms 2904 KB Output is correct
17 Correct 53 ms 2908 KB Output is correct
18 Correct 55 ms 2904 KB Output is correct
19 Correct 55 ms 2908 KB Output is correct
20 Correct 54 ms 2904 KB Output is correct
21 Correct 54 ms 2652 KB Output is correct
22 Correct 53 ms 2872 KB Output is correct
23 Correct 55 ms 2904 KB Output is correct
24 Correct 61 ms 3672 KB Output is correct
25 Correct 62 ms 3828 KB Output is correct
26 Correct 61 ms 3676 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 436 KB Output is correct
29 Correct 1 ms 344 KB Output is correct
30 Correct 1 ms 344 KB Output is correct
31 Correct 1 ms 348 KB Output is correct
32 Correct 1 ms 348 KB Output is correct
33 Correct 2 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 3 ms 348 KB Output is correct
36 Correct 29 ms 1884 KB Output is correct
37 Correct 33 ms 1744 KB Output is correct
38 Correct 13 ms 1116 KB Output is correct
39 Correct 25 ms 2140 KB Output is correct
40 Correct 23 ms 2140 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 348 KB Output is correct
43 Correct 19 ms 1988 KB Output is correct
44 Correct 18 ms 348 KB Output is correct
45 Correct 11 ms 1372 KB Output is correct
46 Correct 4 ms 860 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 2 ms 348 KB Output is correct
49 Correct 4 ms 436 KB Output is correct
50 Correct 5 ms 348 KB Output is correct
51 Correct 7 ms 348 KB Output is correct
52 Correct 8 ms 348 KB Output is correct
53 Correct 55 ms 2912 KB Output is correct
54 Correct 55 ms 2908 KB Output is correct
55 Correct 55 ms 2904 KB Output is correct
56 Correct 57 ms 2908 KB Output is correct
57 Correct 55 ms 2908 KB Output is correct
58 Correct 54 ms 2904 KB Output is correct
59 Correct 57 ms 2908 KB Output is correct
60 Correct 52 ms 348 KB Output is correct
61 Correct 54 ms 2652 KB Output is correct
62 Correct 52 ms 468 KB Output is correct
63 Correct 54 ms 2908 KB Output is correct
64 Correct 52 ms 344 KB Output is correct
65 Correct 11 ms 348 KB Output is correct
66 Correct 3 ms 348 KB Output is correct
67 Correct 25 ms 348 KB Output is correct
68 Correct 10 ms 448 KB Output is correct
69 Correct 20 ms 460 KB Output is correct
70 Correct 40 ms 2548 KB Output is correct
71 Correct 31 ms 1880 KB Output is correct
72 Correct 9 ms 1112 KB Output is correct
73 Correct 1 ms 604 KB Output is correct
74 Correct 13 ms 1476 KB Output is correct
75 Correct 28 ms 2748 KB Output is correct
76 Correct 19 ms 2908 KB Output is correct
77 Correct 9 ms 2140 KB Output is correct
78 Correct 13 ms 2652 KB Output is correct
79 Correct 52 ms 348 KB Output is correct
80 Correct 53 ms 348 KB Output is correct
81 Correct 52 ms 432 KB Output is correct
82 Correct 52 ms 344 KB Output is correct
83 Correct 52 ms 348 KB Output is correct
84 Correct 56 ms 2908 KB Output is correct
85 Correct 56 ms 2904 KB Output is correct
86 Correct 58 ms 3088 KB Output is correct
87 Correct 57 ms 2904 KB Output is correct
88 Correct 55 ms 2908 KB Output is correct
89 Correct 55 ms 2908 KB Output is correct
90 Correct 69 ms 4956 KB Output is correct
91 Correct 66 ms 4956 KB Output is correct
92 Correct 66 ms 5024 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 57 ms 2908 KB Output is correct
16 Correct 56 ms 2904 KB Output is correct
17 Correct 53 ms 2908 KB Output is correct
18 Correct 55 ms 2904 KB Output is correct
19 Correct 55 ms 2908 KB Output is correct
20 Correct 54 ms 2904 KB Output is correct
21 Correct 54 ms 2652 KB Output is correct
22 Correct 53 ms 2872 KB Output is correct
23 Correct 55 ms 2904 KB Output is correct
24 Correct 61 ms 3672 KB Output is correct
25 Correct 62 ms 3828 KB Output is correct
26 Correct 61 ms 3676 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Execution timed out 1593 ms 25356 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 600 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 1 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 348 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 57 ms 2908 KB Output is correct
16 Correct 56 ms 2904 KB Output is correct
17 Correct 53 ms 2908 KB Output is correct
18 Correct 55 ms 2904 KB Output is correct
19 Correct 55 ms 2908 KB Output is correct
20 Correct 54 ms 2904 KB Output is correct
21 Correct 54 ms 2652 KB Output is correct
22 Correct 53 ms 2872 KB Output is correct
23 Correct 55 ms 2904 KB Output is correct
24 Correct 61 ms 3672 KB Output is correct
25 Correct 62 ms 3828 KB Output is correct
26 Correct 61 ms 3676 KB Output is correct
27 Correct 2 ms 348 KB Output is correct
28 Correct 2 ms 348 KB Output is correct
29 Correct 2 ms 512 KB Output is correct
30 Correct 2 ms 348 KB Output is correct
31 Correct 3 ms 348 KB Output is correct
32 Correct 4 ms 348 KB Output is correct
33 Execution timed out 1593 ms 25356 KB Time limit exceeded
34 Halted 0 ms 0 KB -