답안 #981877

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
981877 2024-05-13T15:56:51 Z Abito 벽 칠하기 (APIO20_paint) C++17
12 / 100
45 ms 12304 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],r[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;
    r[n]=n;
    for (int i=n-1;i;i--){
        r[i]=i;
        if ((d[c[i]]+1)%m==d[c[i+1]]) r[i]=r[i+1];
    }
    //for (int i=1;i<=n;i++) cout<<r[i]<<' ';cout<<endl;
    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 (r[i]-i+1>=m) dp[i]=*s.begin()+1;
        s.erase(s.find(dp[i+m]));
        s.ep(dp[i]);
    }
    //for (int i=1;i<=n;i++) cout<<dp[i]<<' ';cout<<endl;
    if (dp[1]>=N) return -1;
    return dp[1];
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 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 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 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 680 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 704 KB Output is correct
18 Correct 1 ms 856 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 704 KB Output is correct
21 Correct 1 ms 860 KB Output is correct
22 Correct 8 ms 2112 KB Output is correct
23 Correct 8 ms 2140 KB Output is correct
24 Correct 8 ms 2140 KB Output is correct
25 Correct 2 ms 860 KB Output is correct
26 Correct 2 ms 860 KB Output is correct
27 Correct 2 ms 856 KB Output is correct
28 Correct 3 ms 860 KB Output is correct
29 Correct 3 ms 860 KB Output is correct
30 Correct 3 ms 860 KB Output is correct
31 Correct 6 ms 1628 KB Output is correct
32 Correct 6 ms 1628 KB Output is correct
33 Correct 6 ms 1704 KB Output is correct
34 Correct 6 ms 1624 KB Output is correct
35 Correct 6 ms 1628 KB Output is correct
36 Correct 6 ms 1628 KB Output is correct
37 Correct 11 ms 2908 KB Output is correct
38 Correct 11 ms 2760 KB Output is correct
39 Correct 11 ms 3160 KB Output is correct
40 Correct 9 ms 2396 KB Output is correct
41 Correct 6 ms 1628 KB Output is correct
42 Correct 11 ms 2584 KB Output is correct
43 Correct 8 ms 1624 KB Output is correct
44 Correct 9 ms 1628 KB Output is correct
45 Correct 11 ms 2396 KB Output is correct
46 Correct 38 ms 11508 KB Output is correct
47 Correct 23 ms 6484 KB Output is correct
48 Correct 32 ms 10068 KB Output is correct
49 Correct 30 ms 9308 KB Output is correct
50 Correct 29 ms 8540 KB Output is correct
51 Correct 26 ms 6168 KB Output is correct
52 Correct 10 ms 2392 KB Output is correct
53 Correct 10 ms 2396 KB Output is correct
54 Correct 11 ms 2396 KB Output is correct
55 Correct 11 ms 2396 KB Output is correct
56 Correct 11 ms 2380 KB Output is correct
57 Correct 11 ms 2648 KB Output is correct
58 Correct 44 ms 12228 KB Output is correct
59 Correct 43 ms 12132 KB Output is correct
60 Correct 43 ms 12112 KB Output is correct
61 Correct 43 ms 12116 KB Output is correct
62 Correct 43 ms 12112 KB Output is correct
63 Correct 45 ms 12304 KB Output is correct
64 Correct 40 ms 11092 KB Output is correct
65 Correct 45 ms 11036 KB Output is correct
66 Correct 44 ms 10932 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 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 0 ms 348 KB Output is correct
10 Correct 1 ms 344 KB Output is correct
11 Correct 0 ms 348 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 680 KB Output is correct
16 Correct 1 ms 860 KB Output is correct
17 Correct 1 ms 704 KB Output is correct
18 Correct 1 ms 856 KB Output is correct
19 Correct 1 ms 860 KB Output is correct
20 Correct 1 ms 704 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 -