제출 #409820

#제출 시각아이디문제언어결과실행 시간메모리
409820jhwest2벽 칠하기 (APIO20_paint)C++14
100 / 100
433 ms255336 KiB
#include "paint.h" #include <bits/stdc++.h> #define va first #define vb second using namespace std; typedef long long lint; typedef pair<int, int> pint; const int M = 1e5 + 10; const int INF = 1e9; int n, m, k, Chk[M]; vector<int> Dp[M], D[M]; priority_queue<int, vector<int>, greater<int>> Q; 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 x : B[i]) D[x].push_back(i); } Dp[0].resize(D[C[0]].size(), 0); if (m == 1 && !Dp[0].empty()) Q.push(0); for (int i = 1; i < n; i++) { vector<int> &V = D[C[i]]; vector<int> &W = D[C[i - 1]]; if (i >= 2) Dp[i - 2].clear(); Dp[i].resize(V.size(), 0); if (W.empty()) continue; int k = 0, f = 0; for (int j = 0; j < V.size(); j++) { if (V[j] == 0) { if (W.back() == m - 1) Dp[i][j] = Dp[i - 1].back() + 1; } else { for (; k < W.size(); k++) { if (W[k] >= V[j] - 1) break; } if (k == W.size() || W[k] != V[j] - 1) continue; Dp[i][j] = Dp[i - 1][k] + 1; } if (!f && Dp[i][j] >= m - 1) { Q.push(i - m + 1); f = 1; } } } if (Q.empty() || Q.top() != 0) return -1; int ret = 0; while (!Q.empty()) { int x = Q.top(); Q.pop(); ++ret; while (!Q.empty()) { int t = Q.top(); Q.pop(); if (Q.empty() || Q.top() > x + m) { Q.push(t); break; } } if (Q.empty()) { if (x == n - m) break; return -1; } if (Q.top() > x + m) return -1; } return ret; }

컴파일 시 표준 에러 (stderr) 메시지

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:29:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |   for (int j = 0; j < V.size(); j++) {
      |                   ~~^~~~~~~~~~
paint.cpp:34:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   34 |     for (; k < W.size(); k++) {
      |            ~~^~~~~~~~~~
paint.cpp:37:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |     if (k == W.size() || W[k] != V[j] - 1) continue;
      |         ~~^~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...