# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
409941 | 2021-05-21T19:33:17 Z | Carmel_Ab1 | Painting Walls (APIO20_paint) | C++17 | 1 ms | 204 KB |
#include <bits/stdc++.h> #include "paint.h" //#include "grader.cpp" using namespace std; typedef vector<int> vi; typedef vector<vi> vvi; #define all(x) x.begin(),x.end() int minimumInstructions(int N, int M, int K, vi C,vi A, vvi B) { for(int i=0; i<B.size(); i++) sort(all(B[i])); vector<vector<bool>>can(N,vector<bool>(M));// iff a sequence from j can start in i for(int i=0; i+M<=N;i++){ for(int j=0; j<M; j++){ can[i][j]=1; for(int j2=0; j2<M; j2++) if(!binary_search(all(B[(j+j2)%M]),C[(i+j2)])) { can[i][j] = 0; break; } } } set<int>segs; for(int i=0; i<N; i++) for(int j=0; j<M; j++) if(can[i][j]) segs.insert(i); int ans=0; vector<bool>covered(N); for(int i=0; i<N;i++){ if(covered[i])continue; ans++; if(segs.empty())return -1; auto ub=segs.upper_bound(i); ub--; if(*ub+M<i)return -1; for(int j=*ub; j<*ub+M; j++) covered[j]=1; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Correct | 1 ms | 204 KB | Output is correct |
3 | Incorrect | 1 ms | 204 KB | Output isn't correct |
4 | Halted | 0 ms | 0 KB | - |