답안 #982692

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982692 2024-05-14T16:10:01 Z stegatxins0 벽 칠하기 (APIO20_paint) C++17
0 / 100
7 ms 1884 KB
#include <bits/stdc++.h>
#include "paint.h"
using namespace std;

#ifdef DEBUG
#include "debug.cpp"
#else
#define dbg(...)
#define dbgarr(...)
#endif

// const int mxM = 50001;
// int f[mxM];
//
const int mxN = 1e5+1;
int mp[mxN], ok[mxN];
bool like[mxN];

int minimumInstructions(
    int N, int M, int K, std::vector<int> C,
    std::vector<int> A, std::vector<std::vector<int>> B) {

    memset(mp,0,sizeof(mp));
    memset(like,0,sizeof(like));
    memset(ok,0,sizeof(ok));

    // since each contarctor can only like one color, if no of contractor less than no of color,
    // if(M < K)return -1; // NOTE: B might have color not in C
    for(int i=0; i<M; i++){
        for(int j=0; j<A[i]; j++){
            like[B[i][j]] = 1;
        }
    }
    for(int i=1; i<=K; i++){
        if(like[i] == 0 && binary_search(C.begin(), C.end(), i))return -1;
    }

    deque<int> q;

    int curunq = 0;

    for(int i=0; i<N; i++){
        if(i >= M){
            mp[C[i - M]]--;
            if(mp[C[i - M]] == 0){
                curunq--;
            }
            q.pop_back();
        }
        q.push_front(C[i]);
        mp[C[i]]++;
        if(mp[C[i]] <= 1){
            curunq++;
        }
        if(curunq == M)ok[i] = 1;
    }

    dbgarr(ok,N);
    if(!ok[M-1] || !ok[N-1])return -1;

    int jump = 1;

    int p = M-1, tojump;
    while(p < N-1){
        tojump = -1;
        for(int i=min(p+M,N-1); i>=p+1; i--){
            if(ok[i]){
                tojump = i;
                break;
            }
        }
        if(tojump == -1)return -1;

        jump++;
        p = tojump;
        // dbg(p, p+M);

    }


  return jump;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1112 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1168 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 2 ms 1112 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 2 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 1 ms 1112 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Incorrect 7 ms 1884 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 1116 KB Output is correct
2 Correct 1 ms 1116 KB Output is correct
3 Correct 1 ms 1116 KB Output is correct
4 Correct 1 ms 1116 KB Output is correct
5 Correct 1 ms 1116 KB Output is correct
6 Correct 1 ms 1116 KB Output is correct
7 Correct 1 ms 1116 KB Output is correct
8 Correct 1 ms 1112 KB Output is correct
9 Correct 1 ms 1112 KB Output is correct
10 Correct 1 ms 1116 KB Output is correct
11 Correct 1 ms 1168 KB Output is correct
12 Correct 1 ms 1116 KB Output is correct
13 Correct 2 ms 1112 KB Output is correct
14 Correct 1 ms 1116 KB Output is correct
15 Correct 1 ms 1116 KB Output is correct
16 Correct 2 ms 1116 KB Output is correct
17 Correct 1 ms 1116 KB Output is correct
18 Correct 1 ms 1116 KB Output is correct
19 Correct 1 ms 1116 KB Output is correct
20 Correct 1 ms 1112 KB Output is correct
21 Correct 1 ms 1116 KB Output is correct
22 Incorrect 1 ms 1116 KB Output isn't correct
23 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 1116 KB Output isn't correct
2 Halted 0 ms 0 KB -