답안 #982685

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
982685 2024-05-14T16:03:40 Z stegatxins0 벽 칠하기 (APIO20_paint) C++17
0 / 100
1 ms 1116 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];

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(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()

    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 Incorrect 1 ms 1116 KB Output isn't correct
5 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 Incorrect 1 ms 1116 KB Output isn't correct
5 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 Incorrect 1 ms 1116 KB Output isn't correct
5 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 Incorrect 1 ms 1116 KB Output isn't correct
5 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 Incorrect 1 ms 1116 KB Output isn't correct
5 Halted 0 ms 0 KB -