Submission #898288

# Submission time Handle Problem Language Result Execution time Memory
898288 2024-01-04T12:40:42 Z irmuun Painting Walls (APIO20_paint) C++17
12 / 100
37 ms 9092 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<int>can(k,-1);
    for(int i=0;i<m;i++){
        for(int j=0;j<A[i];j++){
            can[B[i][j]]=i;
        }
    }
    for(int i=0;i<n;i++){
        if(can[C[i]]==-1) return -1;
    }
    vector<int>count(n,0);
    int cur=1;
    count[n-1]=1;
    for(int i=n-2;i>=0;i--){
        if(can[C[i]]==can[C[i+1]]-1||(can[C[i+1]]==0&&can[C[i]]==m-1)){
            cur++;
        }
        else{
            cur=1;
        }
        count[i]=cur;
    }
    int ans=0;
    bool ok=true;
    if(count[0]<m) return -1;
    ans++;
    int r=m-1,nxt=0;
    for(int i=1;i<n;i++){
        if(count[i]>=m){
            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:36:10: warning: unused variable 'ok' [-Wunused-variable]
   36 |     bool ok=true;
      |          ^~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 432 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 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 1 ms 436 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 696 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 856 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 7 ms 2120 KB Output is correct
23 Correct 9 ms 2140 KB Output is correct
24 Correct 7 ms 2136 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 2 ms 604 KB Output is correct
28 Correct 2 ms 604 KB Output is correct
29 Correct 2 ms 604 KB Output is correct
30 Correct 2 ms 600 KB Output is correct
31 Correct 4 ms 1368 KB Output is correct
32 Correct 4 ms 1372 KB Output is correct
33 Correct 4 ms 1476 KB Output is correct
34 Correct 4 ms 1368 KB Output is correct
35 Correct 5 ms 1372 KB Output is correct
36 Correct 4 ms 1372 KB Output is correct
37 Correct 9 ms 2464 KB Output is correct
38 Correct 10 ms 2652 KB Output is correct
39 Correct 9 ms 2648 KB Output is correct
40 Correct 6 ms 1624 KB Output is correct
41 Correct 4 ms 1116 KB Output is correct
42 Correct 8 ms 1728 KB Output is correct
43 Correct 7 ms 1340 KB Output is correct
44 Correct 5 ms 1116 KB Output is correct
45 Correct 10 ms 1884 KB Output is correct
46 Correct 37 ms 8540 KB Output is correct
47 Correct 13 ms 4956 KB Output is correct
48 Correct 28 ms 7452 KB Output is correct
49 Correct 24 ms 7192 KB Output is correct
50 Correct 28 ms 6484 KB Output is correct
51 Correct 19 ms 4700 KB Output is correct
52 Correct 7 ms 1628 KB Output is correct
53 Correct 6 ms 1628 KB Output is correct
54 Correct 7 ms 1628 KB Output is correct
55 Correct 7 ms 1816 KB Output is correct
56 Correct 7 ms 1628 KB Output is correct
57 Correct 9 ms 1628 KB Output is correct
58 Correct 28 ms 9052 KB Output is correct
59 Correct 24 ms 9048 KB Output is correct
60 Correct 33 ms 9052 KB Output is correct
61 Correct 24 ms 9092 KB Output is correct
62 Correct 25 ms 9052 KB Output is correct
63 Correct 26 ms 8884 KB Output is correct
64 Correct 37 ms 8276 KB Output is correct
65 Correct 24 ms 8284 KB Output is correct
66 Correct 34 ms 8104 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 ms 600 KB Output is correct
4 Correct 0 ms 432 KB Output is correct
5 Correct 1 ms 344 KB Output is correct
6 Correct 1 ms 348 KB Output is correct
7 Correct 1 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 1 ms 436 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 860 KB Output is correct
14 Correct 1 ms 860 KB Output is correct
15 Correct 1 ms 860 KB Output is correct
16 Correct 1 ms 696 KB Output is correct
17 Correct 1 ms 860 KB Output is correct
18 Correct 1 ms 860 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 856 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Incorrect 1 ms 344 KB Output isn't correct
23 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -