# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
569791 | 2022-05-27T19:55:26 Z | aryan12 | 벽 칠하기 (APIO20_paint) | C++17 | 0 ms | 212 KB |
#include "paint.h" #include <bits/stdc++.h> using namespace std; int minimumInstructions(int N, int M, int K, vector<int> colors, vector<int> num, vector<vector<int> > likes) { vector<vector<int> > dp(N, vector<int> (M, -1e9)); set<int> likings[M]; for(int contractor = 0; contractor < M; contractor++) { for(int j = 0; j < num[contractor]; j++) { likings[contractor].insert(likes[contractor][j]); } } for(int i = N - 1; i >= 0; i--) { for(int j = 0; j < M; j++) { if(likings[j].count(colors[i])) { if(i == N - 1 || dp[i + 1][(j + 1) % M] == -1e9) { dp[i][j] = 1; } else { dp[i][j] = dp[i + 1][(j + 1) % M] + 1; } } } } vector<int> start_pos; for(int i = N - M; i >= 0; i--) { for(int j = 0; j < M; j++) { if(dp[i][j] >= M) { start_pos.push_back(i); // cout << i << "\n"; break; } } } int ans = 0; int min_x = N; for(int i = 0; i < start_pos.size(); i++) { // cout << "start_pos[i] = " << start_pos[i] << ", M = " << M << ", minx = " << min_x << "\n"; if(i == start_pos.size() - 1 || start_pos[i + 1] + M - 1 < min_x - 1 || start_pos[i] == 0) { min_x = start_pos[i]; ans++; } } if(min_x != 0) return -1; return ans; }
Compilation message
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | 결과 | 실행 시간 | 메모리 | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Incorrect | 0 ms | 212 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |