# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
922772 | 2024-02-06T06:14:41 Z | salmon | Painting Walls (APIO20_paint) | C++14 | 9 ms | 17240 KB |
#include "paint.h" #include <bits/stdc++.h> using namespace std; set<int> lst[100100]; vector<int> pos[50100]; vector<int> contract[100100]; bool can[100100]; bool l[100100]; int minimumInstructions(int N, int M, int K, vector<int> C, vector<int> A, vector<vector<int>> B) { for(int i = 0; i < N; i++){ pos[C[i]].push_back(i); can[i] = false; } for(int i = 0; i < M; i++){ for(int j : B[i]){ for(int k : pos[j]){ contract[k].push_back(i); } } } vector<pair<int,int>> v; for(int i = 0; i < N; i++){ int it = 0; int it1 = 0; vector<pair<int,int>> temp; if(contract[i].size() != 0 && contract[i][0] == 0){ if(!v.empty() && v.back().first == M - 1){ temp.push_back({0,v.back().second + 1 }); if(v.back().second + 1 >= M){ can[i] = true; } v.pop_back(); } else{ temp.push_back({0,1}); if(M == 1){ can[i] = true; } } } for(int j : contract[i]){ while(it != v.size() && v[it].first + 1 < j){ it++; } if(it != v.size() && v[it].first + 1 == j){ temp.push_back({v[it].first + 1,v[it].second + 1}); if(v[it].second + 1 >= M){ can[i] = true; } } else{ temp.push_back({j,1}); if(M == 1){ can[i] = true; } } } v = temp; } for(int i = 0; i < N; i++){ if(i + M - 1 < N && can[i + M - 1]) l[i] = true; else l[i] = false; } int ans = 1100100100; if(!l[0]) return -1; int cont = 1; int r = M - 1; int go = N - 1; int it = 0; int take = 0; while(r < go){ cont++; take = r; while(it <= r){ it++; if(l[it]){ take = it + M - 1; } } if(take == r){ cont = 1100100100; break; } r = take; } ans = min(ans,cont); if(ans == 1100100100) return -1; return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8540 KB | Output is correct |
2 | Correct | 3 ms | 8692 KB | Output is correct |
3 | Correct | 2 ms | 8540 KB | Output is correct |
4 | Correct | 3 ms | 8540 KB | Output is correct |
5 | Correct | 2 ms | 8540 KB | Output is correct |
6 | Correct | 2 ms | 8540 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 8540 KB | Output is correct |
9 | Correct | 2 ms | 8540 KB | Output is correct |
10 | Correct | 2 ms | 8540 KB | Output is correct |
11 | Correct | 2 ms | 8540 KB | Output is correct |
12 | Correct | 2 ms | 8540 KB | Output is correct |
13 | Runtime error | 9 ms | 17240 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8540 KB | Output is correct |
2 | Correct | 3 ms | 8692 KB | Output is correct |
3 | Correct | 2 ms | 8540 KB | Output is correct |
4 | Correct | 3 ms | 8540 KB | Output is correct |
5 | Correct | 2 ms | 8540 KB | Output is correct |
6 | Correct | 2 ms | 8540 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 8540 KB | Output is correct |
9 | Correct | 2 ms | 8540 KB | Output is correct |
10 | Correct | 2 ms | 8540 KB | Output is correct |
11 | Correct | 2 ms | 8540 KB | Output is correct |
12 | Correct | 2 ms | 8540 KB | Output is correct |
13 | Runtime error | 9 ms | 17240 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8540 KB | Output is correct |
2 | Correct | 3 ms | 8692 KB | Output is correct |
3 | Correct | 2 ms | 8540 KB | Output is correct |
4 | Correct | 3 ms | 8540 KB | Output is correct |
5 | Correct | 2 ms | 8540 KB | Output is correct |
6 | Correct | 2 ms | 8540 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 8540 KB | Output is correct |
9 | Correct | 2 ms | 8540 KB | Output is correct |
10 | Correct | 2 ms | 8540 KB | Output is correct |
11 | Correct | 2 ms | 8540 KB | Output is correct |
12 | Correct | 2 ms | 8540 KB | Output is correct |
13 | Runtime error | 9 ms | 17240 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8540 KB | Output is correct |
2 | Correct | 3 ms | 8692 KB | Output is correct |
3 | Correct | 2 ms | 8540 KB | Output is correct |
4 | Correct | 3 ms | 8540 KB | Output is correct |
5 | Correct | 2 ms | 8540 KB | Output is correct |
6 | Correct | 2 ms | 8540 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 8540 KB | Output is correct |
9 | Correct | 2 ms | 8540 KB | Output is correct |
10 | Correct | 2 ms | 8540 KB | Output is correct |
11 | Correct | 2 ms | 8540 KB | Output is correct |
12 | Correct | 2 ms | 8540 KB | Output is correct |
13 | Runtime error | 9 ms | 17240 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 2 ms | 8540 KB | Output is correct |
2 | Correct | 3 ms | 8692 KB | Output is correct |
3 | Correct | 2 ms | 8540 KB | Output is correct |
4 | Correct | 3 ms | 8540 KB | Output is correct |
5 | Correct | 2 ms | 8540 KB | Output is correct |
6 | Correct | 2 ms | 8540 KB | Output is correct |
7 | Correct | 2 ms | 8540 KB | Output is correct |
8 | Correct | 2 ms | 8540 KB | Output is correct |
9 | Correct | 2 ms | 8540 KB | Output is correct |
10 | Correct | 2 ms | 8540 KB | Output is correct |
11 | Correct | 2 ms | 8540 KB | Output is correct |
12 | Correct | 2 ms | 8540 KB | Output is correct |
13 | Runtime error | 9 ms | 17240 KB | Execution killed with signal 11 |
14 | Halted | 0 ms | 0 KB | - |