제출 #558700

#제출 시각아이디문제언어결과실행 시간메모리
558700Ai7081벽 칠하기 (APIO20_paint)C++17
63 / 100
1584 ms13028 KiB
#include "paint.h" #include <bits/stdc++.h> using namespace std; const int inf = 1e9; int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) { vector<int> col[K+5]; for (int i=0; i<B.size(); i++) for (auto it : B[i]) col[it].push_back(i); vector<int> dp(N+5, inf); vector<int> cnt(M+5, 0); deque<pair<int, int>> dq; int n_good = 0; for (int i=0; i<N; i++) { if (i >= M) { for (auto j : col[C[i-M]]) { int ver = (M+(j-i)%M)%M; if (cnt[ver] == M) n_good--; cnt[ver]--; } } for (auto j : col[C[i]]) { int ver = (M+(j-i)%M)%M; cnt[ver]++; if (cnt[ver] == M) n_good++; } if (n_good) { if (i == M-1) dp[i] = 1; else { while (!dq.empty() && dq.front().second < i-M) dq.pop_front(); if (!dq.empty()) dp[i] = dq.front().first + 1; } while (!dq.empty() && dq.back().first >= dp[i]) dq.pop_back(); dq.push_back({dp[i], i}); } } return (dp[N-1] < inf ? dp[N-1] : -1); }

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

paint.cpp: In function 'int minimumInstructions(int, int, int, std::vector<int>, std::vector<int>, std::vector<std::vector<int> >)':
paint.cpp:10:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::vector<int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for (int i=0; i<B.size(); i++) for (auto it : B[i]) col[it].push_back(i);
      |                   ~^~~~~~~~~
#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...