# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
724122 | 2023-04-14T18:17:46 Z | danikoynov | Painting Walls (APIO20_paint) | C++14 | 1 ms | 468 KB |
#include "paint.h" #include <bits/stdc++.h> using namespace std; const int maxn = 510, maxk = 1e5 + 10; int dp[maxn], c[maxn], a[maxn], n, m; vector < int > b[maxn], col[maxn]; vector < pair < int, int > > path[maxn]; int minimumInstructions( int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) { n = N; m = M; for (int i = 0; i < n; i ++) { c[i] = C[i]; } for (int i = 0; i < m; i ++) { a[i] = A[i]; for (int j = 0; j < a[i]; j ++) { b[i].push_back(B[i][j]); col[b[i][j]].push_back(i); } } for (int i = 0; i < N; i ++) dp[i] = 1e9; for (int i = N - 1; i >= 0; i --) { for (int idx : col[c[i]]) path[i].push_back({idx, 1}); } for (int i = N - 1; i >= 0; i --) { /**bool tf = false; for (int st = 0; st < M; st ++) { bool is_pos = true; for (int pos = 0; pos < M; pos ++) { if (col[c[i + pos]][(st + pos) % M] == 0) { ///cout << "break " << pos << endl; is_pos = false; break; } } if (is_pos) { ///cout << i << " " << st << endl; tf = true; break; } }*/ bool tf = false; int pt = 0; for (int j = 0; j < path[i].size(); j ++) { while(pt < path[i + 1].size() && path[i + 1][pt].first <= path[i][j].first) pt ++; if (pt != path[i + 1].size() && path[i + 1][pt].first == path[i][j].first + 1) path[i][j].second = max(path[i][j].second, min(path[i + 1][pt].second + 1, m)); if (path[i][j].first == M - 1) { if (path[i + 1].size() > 0 && path[i + 1][0].first == 0) { path[i][j].second = max(path[i][j].second, min(path[i + 1][0].second + 1, m)); } } if (path[i][j].second == m) tf = true; ///cout << i << " : " << path[i][j].first << " " << path[i][j].second << endl; } if (tf) { for (int j = i + 1; j <= i + M; j ++) dp[i] = min(dp[i], dp[j] + 1); } } if (dp[0] > N) return -1; return dp[0]; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 340 KB | Output is correct |
2 | Correct | 1 ms | 340 KB | Output is correct |
3 | Correct | 1 ms | 340 KB | Output is correct |
4 | Correct | 1 ms | 340 KB | Output is correct |
5 | Correct | 1 ms | 340 KB | Output is correct |
6 | Correct | 1 ms | 340 KB | Output is correct |
7 | Correct | 1 ms | 348 KB | Output is correct |
8 | Correct | 1 ms | 340 KB | Output is correct |
9 | Correct | 1 ms | 340 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Runtime error | 1 ms | 468 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |