Submission #1106166

# Submission time Handle Problem Language Result Execution time Memory
1106166 2024-10-29T12:25:14 Z vladilius Painting Walls (APIO20_paint) C++17
0 / 100
397 ms 524288 KB
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define pb push_back
#define ff first
#define ss second

int minimumInstructions(int n, int m, int k, vector<int> x, vector<int> A, vector<vector<int>> B){
    vector<vector<bool>> f(m, vector<bool>(k));
    for (int i = 0; i < m; i++){
        for (int j: B[i]){
            f[i][j] = 1;
        }
    }
    vector<int> T[n];
    for (int i = 0; i < n; i++){
        for (int j = 0; j < m; j++){
            if (f[j][x[i]]){
                T[i].pb(j);
            }
        }
        int q = (int) T[i].size();
        for (int j = 0; j < q; j++){
            T[i].pb(T[i][j] + m);
        }
        
        for (int j = 0; j < T[i].size(); j++) T[i][j] -= i;
    }
    
    map<int, vector<int>> mp;
    for (int i = 0; i < n; i++){
        for (int j: T[i]){
            mp[j].pb(i);
        }
    }
    
    vector<bool> gd(n);
    for (auto [y, V]: mp){
        int i = 0;
        while (i < V.size()){
            int j = i;
            while (j + 1 < V.size() && (V[j] + 1) == V[j + 1]) j++;
            for (int t = V[i]; t <= V[j] - m + 1; t++) gd[t] = 1;
            
            i = j + 1;
        }
    }
    
    int mx = -1, t = 0, out = 0;
    for (int i = 0; i < n; i++){
        if (gd[i]) t = max(t, i);
        if (i == (mx + 1)){
            if (t == -1) return -1;
            mx = t + m - 1;
            t = -1;
            out++;
        }
    }
    return out;
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:28:27: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   28 |         for (int j = 0; j < T[i].size(); j++) T[i][j] -= i;
      |                         ~~^~~~~~~~~~~~~
paint.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |         while (i < V.size()){
      |                ~~^~~~~~~~~~
paint.cpp:43:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   43 |             while (j + 1 < V.size() && (V[j] + 1) == V[j + 1]) j++;
      |                    ~~~~~~^~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 3 ms 2896 KB Output is correct
14 Correct 3 ms 2896 KB Output is correct
15 Correct 3 ms 2896 KB Output is correct
16 Correct 3 ms 2896 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 3 ms 2896 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 2 ms 2896 KB Output is correct
22 Correct 13 ms 3528 KB Output is correct
23 Correct 9 ms 3916 KB Output is correct
24 Correct 10 ms 3752 KB Output is correct
25 Correct 11 ms 3664 KB Output is correct
26 Correct 11 ms 3664 KB Output is correct
27 Correct 9 ms 3664 KB Output is correct
28 Correct 9 ms 3664 KB Output is correct
29 Correct 10 ms 3500 KB Output is correct
30 Correct 10 ms 3408 KB Output is correct
31 Correct 300 ms 26696 KB Output is correct
32 Correct 284 ms 26696 KB Output is correct
33 Correct 284 ms 26696 KB Output is correct
34 Correct 226 ms 26696 KB Output is correct
35 Correct 291 ms 26696 KB Output is correct
36 Correct 300 ms 26692 KB Output is correct
37 Correct 257 ms 29132 KB Output is correct
38 Correct 276 ms 29000 KB Output is correct
39 Correct 275 ms 29012 KB Output is correct
40 Correct 51 ms 15952 KB Output is correct
41 Correct 29 ms 10064 KB Output is correct
42 Correct 49 ms 16540 KB Output is correct
43 Correct 38 ms 11088 KB Output is correct
44 Correct 29 ms 9820 KB Output is correct
45 Correct 49 ms 16456 KB Output is correct
46 Runtime error 397 ms 524288 KB Execution killed with signal 9
47 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 1 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 3 ms 2896 KB Output is correct
14 Correct 3 ms 2896 KB Output is correct
15 Correct 3 ms 2896 KB Output is correct
16 Correct 3 ms 2896 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 3 ms 2896 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 2 ms 2896 KB Output is correct
22 Correct 1 ms 336 KB Output is correct
23 Correct 1 ms 336 KB Output is correct
24 Correct 1 ms 336 KB Output is correct
25 Incorrect 1 ms 336 KB Output isn't correct
26 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 3 ms 2896 KB Output is correct
16 Correct 3 ms 2896 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 3 ms 2896 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 3 ms 2896 KB Output is correct
22 Correct 3 ms 2896 KB Output is correct
23 Correct 2 ms 2896 KB Output is correct
24 Correct 13 ms 3528 KB Output is correct
25 Correct 9 ms 3916 KB Output is correct
26 Correct 10 ms 3752 KB Output is correct
27 Correct 1 ms 336 KB Output is correct
28 Incorrect 1 ms 336 KB Output isn't correct
29 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 3 ms 2896 KB Output is correct
16 Correct 3 ms 2896 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 3 ms 2896 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 3 ms 2896 KB Output is correct
22 Correct 3 ms 2896 KB Output is correct
23 Correct 2 ms 2896 KB Output is correct
24 Correct 13 ms 3528 KB Output is correct
25 Correct 9 ms 3916 KB Output is correct
26 Correct 10 ms 3752 KB Output is correct
27 Correct 11 ms 3664 KB Output is correct
28 Correct 11 ms 3664 KB Output is correct
29 Correct 9 ms 3664 KB Output is correct
30 Correct 9 ms 3664 KB Output is correct
31 Correct 10 ms 3500 KB Output is correct
32 Correct 10 ms 3408 KB Output is correct
33 Correct 300 ms 26696 KB Output is correct
34 Correct 284 ms 26696 KB Output is correct
35 Correct 284 ms 26696 KB Output is correct
36 Correct 226 ms 26696 KB Output is correct
37 Correct 291 ms 26696 KB Output is correct
38 Correct 300 ms 26692 KB Output is correct
39 Correct 257 ms 29132 KB Output is correct
40 Correct 276 ms 29000 KB Output is correct
41 Correct 275 ms 29012 KB Output is correct
42 Correct 1 ms 336 KB Output is correct
43 Incorrect 1 ms 336 KB Output isn't correct
44 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB Output is correct
2 Correct 1 ms 336 KB Output is correct
3 Correct 1 ms 336 KB Output is correct
4 Correct 1 ms 336 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 336 KB Output is correct
7 Correct 0 ms 336 KB Output is correct
8 Correct 1 ms 336 KB Output is correct
9 Correct 1 ms 336 KB Output is correct
10 Correct 1 ms 336 KB Output is correct
11 Correct 1 ms 336 KB Output is correct
12 Correct 1 ms 336 KB Output is correct
13 Correct 1 ms 336 KB Output is correct
14 Correct 1 ms 336 KB Output is correct
15 Correct 3 ms 2896 KB Output is correct
16 Correct 3 ms 2896 KB Output is correct
17 Correct 3 ms 2896 KB Output is correct
18 Correct 3 ms 2896 KB Output is correct
19 Correct 3 ms 2896 KB Output is correct
20 Correct 3 ms 2896 KB Output is correct
21 Correct 3 ms 2896 KB Output is correct
22 Correct 3 ms 2896 KB Output is correct
23 Correct 2 ms 2896 KB Output is correct
24 Correct 13 ms 3528 KB Output is correct
25 Correct 9 ms 3916 KB Output is correct
26 Correct 10 ms 3752 KB Output is correct
27 Correct 11 ms 3664 KB Output is correct
28 Correct 11 ms 3664 KB Output is correct
29 Correct 9 ms 3664 KB Output is correct
30 Correct 9 ms 3664 KB Output is correct
31 Correct 10 ms 3500 KB Output is correct
32 Correct 10 ms 3408 KB Output is correct
33 Correct 300 ms 26696 KB Output is correct
34 Correct 284 ms 26696 KB Output is correct
35 Correct 284 ms 26696 KB Output is correct
36 Correct 226 ms 26696 KB Output is correct
37 Correct 291 ms 26696 KB Output is correct
38 Correct 300 ms 26692 KB Output is correct
39 Correct 257 ms 29132 KB Output is correct
40 Correct 276 ms 29000 KB Output is correct
41 Correct 275 ms 29012 KB Output is correct
42 Correct 51 ms 15952 KB Output is correct
43 Correct 29 ms 10064 KB Output is correct
44 Correct 49 ms 16540 KB Output is correct
45 Correct 38 ms 11088 KB Output is correct
46 Correct 29 ms 9820 KB Output is correct
47 Correct 49 ms 16456 KB Output is correct
48 Runtime error 397 ms 524288 KB Execution killed with signal 9
49 Halted 0 ms 0 KB -