# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
410321 | 2021-05-22T13:57:35 Z | Carmel_Ab1 | Painting Walls (APIO20_paint) | C++17 | 1 ms | 332 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() #define pb push_back int minimumInstructions(int N, int M, int K, vi C,vi A, vvi B) { vvi who(K+1); for(int i=0; i<B.size();i++) for(int j=0; j<B[i].size(); j++) who[B[i][j]].pb(i); for(int i=0; i<N; i++) sort(all(B[i])); vvi can(N,vi(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]=M; 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]==M) segs.insert(i); int ans=0; vector<bool>cov(N); for(int i=0; i<N;i++){ if(cov[i])continue; int l=-1; for(int j=0;i-j>=0 && j<M; j++) if(segs.count(i-j)) { l = i - j; break; } if(l==-1)return -1; for(int j=l; j<l+M; j++) cov[j]=1; ans++; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 204 KB | Output is correct |
2 | Runtime error | 1 ms | 332 KB | Execution killed with signal 11 |
3 | Halted | 0 ms | 0 KB | - |