Submission #550498

# Submission time Handle Problem Language Result Execution time Memory
550498 2022-04-18T09:55:23 Z Jarif_Rahman Painting Walls (APIO20_paint) C++17
28 / 100
1500 ms 9072 KB
#include "paint.h"
#include <bits/stdc++.h>
#define pb push_back
#define f first
#define sc second
using namespace std;
typedef long long int ll;
typedef string str;

int minimumInstructions(int n, int m, int K, vector<int> C, vector<int> A, vector<vector<int>> B){
    vector<unordered_set<int>> likes(m);
    for(int i = 0; i < m; i++) for(int x: B[i]) likes[i].insert(x);

    vector<bool> p(n, 0);
    
    for(int i = n-m; i >= 0; i--){
        for(int j = 0; j < m; j++){
            bool ok = 1;
            for(int k = 0; k < m; k++) if(likes[(j+k)%m].find(C[i+k]) == likes[(j+k)%m].end())
                ok = 0;
            p[i] = p[i]|ok;
        }
    }

    int ans = 0, ls = -1, c = 0;
    for(int i = n-1; i >= 0; i--){
        c++;
        if(p[i]) ls = i;
        if(c == m || i == 0){
            if(ls == -1) return -1;
            ans++;
            c=ls-i;
            ls = -1;
        }
    }

    return ans;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 195 ms 356 KB Output is correct
14 Correct 183 ms 360 KB Output is correct
15 Correct 189 ms 360 KB Output is correct
16 Correct 183 ms 368 KB Output is correct
17 Correct 185 ms 340 KB Output is correct
18 Correct 186 ms 360 KB Output is correct
19 Correct 244 ms 380 KB Output is correct
20 Correct 239 ms 380 KB Output is correct
21 Correct 244 ms 340 KB Output is correct
22 Correct 447 ms 5688 KB Output is correct
23 Correct 443 ms 5708 KB Output is correct
24 Correct 445 ms 5716 KB Output is correct
25 Correct 2 ms 468 KB Output is correct
26 Correct 3 ms 468 KB Output is correct
27 Correct 3 ms 468 KB Output is correct
28 Correct 4 ms 468 KB Output is correct
29 Correct 6 ms 440 KB Output is correct
30 Correct 8 ms 492 KB Output is correct
31 Execution timed out 1576 ms 1848 KB Time limit exceeded
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 300 KB Output is correct
10 Correct 1 ms 300 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 304 KB Output is correct
13 Correct 195 ms 356 KB Output is correct
14 Correct 183 ms 360 KB Output is correct
15 Correct 189 ms 360 KB Output is correct
16 Correct 183 ms 368 KB Output is correct
17 Correct 185 ms 340 KB Output is correct
18 Correct 186 ms 360 KB Output is correct
19 Correct 244 ms 380 KB Output is correct
20 Correct 239 ms 380 KB Output is correct
21 Correct 244 ms 340 KB Output is correct
22 Correct 0 ms 212 KB Output is correct
23 Correct 1 ms 212 KB Output is correct
24 Correct 0 ms 212 KB Output is correct
25 Correct 1 ms 212 KB Output is correct
26 Correct 1 ms 212 KB Output is correct
27 Correct 1 ms 304 KB Output is correct
28 Correct 3 ms 212 KB Output is correct
29 Correct 4 ms 212 KB Output is correct
30 Correct 4 ms 212 KB Output is correct
31 Correct 1 ms 212 KB Output is correct
32 Correct 10 ms 212 KB Output is correct
33 Correct 100 ms 348 KB Output is correct
34 Correct 113 ms 348 KB Output is correct
35 Correct 40 ms 340 KB Output is correct
36 Correct 83 ms 340 KB Output is correct
37 Correct 75 ms 348 KB Output is correct
38 Correct 1 ms 340 KB Output is correct
39 Correct 1 ms 212 KB Output is correct
40 Correct 89 ms 368 KB Output is correct
41 Correct 54 ms 340 KB Output is correct
42 Correct 50 ms 344 KB Output is correct
43 Correct 15 ms 304 KB Output is correct
44 Correct 1 ms 212 KB Output is correct
45 Correct 5 ms 212 KB Output is correct
46 Correct 12 ms 212 KB Output is correct
47 Correct 16 ms 316 KB Output is correct
48 Correct 20 ms 316 KB Output is correct
49 Correct 21 ms 324 KB Output is correct
50 Correct 190 ms 308 KB Output is correct
51 Correct 184 ms 360 KB Output is correct
52 Correct 191 ms 356 KB Output is correct
53 Correct 184 ms 360 KB Output is correct
54 Correct 185 ms 340 KB Output is correct
55 Correct 183 ms 304 KB Output is correct
56 Correct 241 ms 380 KB Output is correct
57 Correct 163 ms 364 KB Output is correct
58 Correct 235 ms 340 KB Output is correct
59 Correct 167 ms 340 KB Output is correct
60 Correct 245 ms 380 KB Output is correct
61 Correct 174 ms 356 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 195 ms 356 KB Output is correct
16 Correct 183 ms 360 KB Output is correct
17 Correct 189 ms 360 KB Output is correct
18 Correct 183 ms 368 KB Output is correct
19 Correct 185 ms 340 KB Output is correct
20 Correct 186 ms 360 KB Output is correct
21 Correct 244 ms 380 KB Output is correct
22 Correct 239 ms 380 KB Output is correct
23 Correct 244 ms 340 KB Output is correct
24 Correct 447 ms 5688 KB Output is correct
25 Correct 443 ms 5708 KB Output is correct
26 Correct 445 ms 5716 KB Output is correct
27 Correct 0 ms 212 KB Output is correct
28 Correct 1 ms 212 KB Output is correct
29 Correct 1 ms 212 KB Output is correct
30 Correct 1 ms 304 KB Output is correct
31 Correct 3 ms 212 KB Output is correct
32 Correct 4 ms 212 KB Output is correct
33 Correct 4 ms 212 KB Output is correct
34 Correct 1 ms 212 KB Output is correct
35 Correct 10 ms 212 KB Output is correct
36 Correct 100 ms 348 KB Output is correct
37 Correct 113 ms 348 KB Output is correct
38 Correct 40 ms 340 KB Output is correct
39 Correct 83 ms 340 KB Output is correct
40 Correct 75 ms 348 KB Output is correct
41 Correct 1 ms 340 KB Output is correct
42 Correct 1 ms 212 KB Output is correct
43 Correct 89 ms 368 KB Output is correct
44 Correct 54 ms 340 KB Output is correct
45 Correct 50 ms 344 KB Output is correct
46 Correct 15 ms 304 KB Output is correct
47 Correct 1 ms 212 KB Output is correct
48 Correct 5 ms 212 KB Output is correct
49 Correct 12 ms 212 KB Output is correct
50 Correct 16 ms 316 KB Output is correct
51 Correct 20 ms 316 KB Output is correct
52 Correct 21 ms 324 KB Output is correct
53 Correct 190 ms 308 KB Output is correct
54 Correct 184 ms 360 KB Output is correct
55 Correct 191 ms 356 KB Output is correct
56 Correct 184 ms 360 KB Output is correct
57 Correct 185 ms 340 KB Output is correct
58 Correct 183 ms 304 KB Output is correct
59 Correct 241 ms 380 KB Output is correct
60 Correct 163 ms 364 KB Output is correct
61 Correct 235 ms 340 KB Output is correct
62 Correct 167 ms 340 KB Output is correct
63 Correct 245 ms 380 KB Output is correct
64 Correct 174 ms 356 KB Output is correct
65 Correct 22 ms 340 KB Output is correct
66 Correct 7 ms 300 KB Output is correct
67 Correct 54 ms 340 KB Output is correct
68 Correct 21 ms 328 KB Output is correct
69 Correct 47 ms 340 KB Output is correct
70 Correct 230 ms 892 KB Output is correct
71 Correct 157 ms 980 KB Output is correct
72 Correct 39 ms 852 KB Output is correct
73 Correct 3 ms 596 KB Output is correct
74 Correct 74 ms 852 KB Output is correct
75 Correct 163 ms 776 KB Output is correct
76 Correct 98 ms 6340 KB Output is correct
77 Correct 24 ms 6796 KB Output is correct
78 Correct 40 ms 8012 KB Output is correct
79 Correct 123 ms 348 KB Output is correct
80 Correct 120 ms 352 KB Output is correct
81 Correct 121 ms 360 KB Output is correct
82 Correct 123 ms 304 KB Output is correct
83 Correct 123 ms 340 KB Output is correct
84 Correct 304 ms 1144 KB Output is correct
85 Correct 318 ms 1144 KB Output is correct
86 Correct 307 ms 1108 KB Output is correct
87 Correct 311 ms 1108 KB Output is correct
88 Correct 301 ms 1140 KB Output is correct
89 Correct 318 ms 1144 KB Output is correct
90 Correct 616 ms 9072 KB Output is correct
91 Correct 563 ms 9056 KB Output is correct
92 Correct 465 ms 9072 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 195 ms 356 KB Output is correct
16 Correct 183 ms 360 KB Output is correct
17 Correct 189 ms 360 KB Output is correct
18 Correct 183 ms 368 KB Output is correct
19 Correct 185 ms 340 KB Output is correct
20 Correct 186 ms 360 KB Output is correct
21 Correct 244 ms 380 KB Output is correct
22 Correct 239 ms 380 KB Output is correct
23 Correct 244 ms 340 KB Output is correct
24 Correct 447 ms 5688 KB Output is correct
25 Correct 443 ms 5708 KB Output is correct
26 Correct 445 ms 5716 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 4 ms 468 KB Output is correct
31 Correct 6 ms 440 KB Output is correct
32 Correct 8 ms 492 KB Output is correct
33 Execution timed out 1576 ms 1848 KB Time limit exceeded
34 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 1 ms 212 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 300 KB Output is correct
12 Correct 1 ms 300 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 195 ms 356 KB Output is correct
16 Correct 183 ms 360 KB Output is correct
17 Correct 189 ms 360 KB Output is correct
18 Correct 183 ms 368 KB Output is correct
19 Correct 185 ms 340 KB Output is correct
20 Correct 186 ms 360 KB Output is correct
21 Correct 244 ms 380 KB Output is correct
22 Correct 239 ms 380 KB Output is correct
23 Correct 244 ms 340 KB Output is correct
24 Correct 447 ms 5688 KB Output is correct
25 Correct 443 ms 5708 KB Output is correct
26 Correct 445 ms 5716 KB Output is correct
27 Correct 2 ms 468 KB Output is correct
28 Correct 3 ms 468 KB Output is correct
29 Correct 3 ms 468 KB Output is correct
30 Correct 4 ms 468 KB Output is correct
31 Correct 6 ms 440 KB Output is correct
32 Correct 8 ms 492 KB Output is correct
33 Execution timed out 1576 ms 1848 KB Time limit exceeded
34 Halted 0 ms 0 KB -