답안 #981498

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
981498 2024-05-13T09:26:01 Z Abito 벽 칠하기 (APIO20_paint) C++17
0 / 100
1 ms 604 KB
#include "paint.h"
#include <bits/stdc++.h>
#define pb push_back
#define ep insert
using namespace std;
int minimumInstructions(
    int n, int m, int k, vector<int> C,
    vector<int> A, vector<vector<int>> B){
    int D[k],p[n];
    for (int i=0;i<n;i++) p[i]=0;
    for (int i=0;i<k;i++) D[i]=-1;
    for (int i=0;i<m;i++) for (auto u:B[i]) D[u]=i;
    for (int i=0;i<k;i++){
        if (D[i]==-1) return -1;
    }
    for (int i=0;i<n-1;i++){
        p[i+1]=p[i];
        p[i+1]+=(D[C[i]]>-1 && D[C[i+1]]>-1 && (D[C[i]]+1)%m==D[C[i+1]]);
    }
    int dp[n+1];
    for (int i=0;i<n;i++) dp[i]=10*n;
    dp[n]=0;
    multiset<int> s;
    for (int i=1;i<m;i++) s.ep(10*n);
    s.ep(0);
    for (int i=n-m;i>=0;i--){
        bool ok=(p[i+m-1]-p[i]==m-1);
        if (ok) dp[i]=*s.begin()+1;
        s.erase(s.find(dp[i+m]));
        s.ep(dp[i]);
    }
    //for (int i=0;i<=n;i++) cout<<dp[i]<<' ';cout<<endl;
    if (dp[0]>=10*n) return -1;
    return dp[0];
}
# 결과 실행 시간 메모리 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 344 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Incorrect 1 ms 604 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Incorrect 1 ms 604 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Incorrect 1 ms 604 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Incorrect 1 ms 604 KB Output isn't correct
14 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 344 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 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Incorrect 1 ms 604 KB Output isn't correct
14 Halted 0 ms 0 KB -