# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1176171 | tkm_algorithms | 벽 칠하기 (APIO20_paint) | C++20 | 0 ms | 524 KiB |
/**
* In the name of Allah
* We are nothing and you're everything
**/
#include <bits/stdc++.h>
//#include "paint.h"
using namespace std;
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
//#define int ll
const char nl = '\n';
//const int inf = 1e18+1;
const int N = 2e4;
const int M = 2e3;
int dp[N+1][M+1];
int minimumInstructions(int n, int m, int k, vector<int> c, vector<int> a, vector<vector<int>> b) {
map<pair<int, int>, int> mp;
for (int i = 0; i < sz(a); ++i) {
for (auto j: b[i])mp[{i, j}] = 1;
}
for (int i = n-1; i >= 0; --i) {
for (int j = 0; j < m; ++j)
if (mp[{j, c[i]}])dp[i][j] = max(dp[i][j], dp[i+1][(j+1)%m]+1);
}
vector<int> p(n+1);
for (int i = 0; i < n; ++i)
for (int j = 0; j < m; ++j)
if (dp[i][j] >= m) {
p[i] = 1;
break;
}
int start = 0;
if (p[0] == 0)return -1;
vector<int> vis(n);
int ans;
while (start < n) {
if (p[start] == 0 || start > n-m)--start;
if (p[start] == 1 && vis[start] == 1) {
return -1;
} else {
ans += 1;
vis[start] = 1;
start += m;
if (start >= n)break;
}
}
if (start >= n)return ans;
}
//ios::sync_with_stdio(false);
//cin.tie(nullptr);
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |