답안 #568232

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
568232 2022-05-25T02:18:31 Z hibiki 벽 칠하기 (APIO20_paint) C++11
0 / 100
3 ms 2644 KB
#include "paint.h"
#include<bits/stdc++.h>
using namespace std;

#define pb push_back
#define f first
#define s second

int n,m,k;
int dp[100100];
deque<int> dq;
vector<int> v[100100];
map<int,int> train;

int minimumInstructions(
    int N, int M, int K, vector<int> C,
    vector<int> A, vector<vector<int>> B)
{
    n = N, m = M, k = K;
    for(int i = 0; i < m; i++)
        for(int j = 0; j < A[i]; j++)
            v[B[i][j]].pb(i);
    dp[n] = 0;
    dq.pb(n);
    for(int i = n - 1; i >= 0; i--)
    {
        bool fi = false;
        map<int,int> temp = train;
        // for(auto val:temp)
        //     printf("%d %d\n",val.f,val.s);
        // printf("---\n");
        train.clear();
        while(dq.back() > i + m)dq.pop_back();
        if(dq.empty())return -1;
        for(int j = 0; j < v[C[i]].size(); j++)
        {
            int cur = v[C[i]][j];
            if(temp[(cur + 1) % m])
            {
                if(temp[(cur + 1) % m] + 1 >= m)
                    fi = true;
                train[cur] = temp[(cur + 1) % m] + 1;
            }
            else
                train[cur] = 1;
        }
        if(fi)
        {
            dp[i] = dp[dq.back()] + 1;
            dq.push_front(i);
        }
    }
    if(dp[0] == 0) return -1;
    return dp[0];
}

Compilation message

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:35:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   35 |         for(int j = 0; j < v[C[i]].size(); j++)
      |                        ~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 3 ms 2644 KB Output isn't correct
2 Halted 0 ms 0 KB -