답안 #981880

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
981880 2024-05-13T15:58:01 Z Abito 벽 칠하기 (APIO20_paint) C++17
12 / 100
44 ms 10996 KB
#include "paint.h"
#include <bits/stdc++.h>
#define pb push_back
#define ep insert
using namespace std;
const int N=1e5+5;
int c[N],dp[N],d[N],p[N];
int minimumInstructions(
    int n, int m, int k, vector<int> C,
    vector<int> A, vector<vector<int>> B){
    for (int i=1;i<=n;i++) c[i]=C[i-1]+1;
    for (int i=1;i<=k;i++) d[i]=-1;
    for (int i=0;i<m;i++) for (auto u:B[i]) d[u+1]=i;
    for (int i=1;i<=n;i++) if (d[c[i]]==-1) return -1;
    for (int i=1;i<n;i++) p[i]=p[i-1]+bool((d[c[i]]+1)%m==d[c[i+1]]);
    for (int i=1;i<=n;i++) dp[i]=N;
    multiset<int> s;s.ep(0);
    for (int i=1;i<m;i++) s.ep(N);
    for (int i=n;i;i--){
        if (i+m>n+1) continue;
        if (p[i+m-2]-p[i-1]==m-1) dp[i]=*s.begin()+1;
        s.erase(s.find(dp[i+m]));
        s.ep(dp[i]);
    }
    if (dp[1]>=N) return -1;
    return dp[1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 344 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 860 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 860 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 8 ms 1624 KB Output is correct
23 Correct 7 ms 1628 KB Output is correct
24 Correct 7 ms 1628 KB Output is correct
25 Correct 2 ms 604 KB Output is correct
26 Correct 2 ms 604 KB Output is correct
27 Correct 3 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 604 KB Output is correct
31 Correct 6 ms 1372 KB Output is correct
32 Correct 5 ms 1372 KB Output is correct
33 Correct 5 ms 1408 KB Output is correct
34 Correct 5 ms 1372 KB Output is correct
35 Correct 6 ms 1372 KB Output is correct
36 Correct 8 ms 1540 KB Output is correct
37 Correct 11 ms 2272 KB Output is correct
38 Correct 11 ms 2336 KB Output is correct
39 Correct 10 ms 2140 KB Output is correct
40 Correct 9 ms 2140 KB Output is correct
41 Correct 7 ms 1372 KB Output is correct
42 Correct 11 ms 2392 KB Output is correct
43 Correct 7 ms 1512 KB Output is correct
44 Correct 6 ms 1880 KB Output is correct
45 Correct 14 ms 2408 KB Output is correct
46 Correct 37 ms 10376 KB Output is correct
47 Correct 22 ms 5724 KB Output is correct
48 Correct 26 ms 9308 KB Output is correct
49 Correct 28 ms 8148 KB Output is correct
50 Correct 30 ms 7772 KB Output is correct
51 Correct 24 ms 5208 KB Output is correct
52 Correct 11 ms 2392 KB Output is correct
53 Correct 10 ms 2396 KB Output is correct
54 Correct 11 ms 2380 KB Output is correct
55 Correct 11 ms 2416 KB Output is correct
56 Correct 11 ms 2396 KB Output is correct
57 Correct 10 ms 2220 KB Output is correct
58 Correct 42 ms 10876 KB Output is correct
59 Correct 42 ms 10844 KB Output is correct
60 Correct 44 ms 10904 KB Output is correct
61 Correct 42 ms 10816 KB Output is correct
62 Correct 44 ms 10996 KB Output is correct
63 Correct 41 ms 10884 KB Output is correct
64 Correct 42 ms 9816 KB Output is correct
65 Correct 39 ms 9832 KB Output is correct
66 Correct 38 ms 9820 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 1 ms 348 KB Output is correct
3 Correct 1 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 344 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 860 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 860 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Incorrect 0 ms 344 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB Output isn't correct
2 Halted 0 ms 0 KB -