# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
289362 | 2020-09-02T15:30:25 Z | beso123 | Painting Walls (APIO20_paint) | C++14 | 1500 ms | 384 KB |
#include "paint.h" #include <bits/stdc++.h> using namespace std; int minimumInstructions(int n,int m,int s,vector<int> col,vector<int> Size,vector<vector<int>> b){ vector<int> mp[s+1]; for(int k=0;k<m;k++){ for(int i=0;i<Size[k];i++){ mp[b[k][i]].push_back(k); } } deque<int> v; v.resize(m,0); for(int k=0;k<m;k++){ for(int i=0;i<mp[col[k]].size();i++){ int nom=mp[col[k]][i]; nom=((nom-k)+m)%m; v[nom]++; } } vector<int> a(n,0); for(int k=0;k<v.size();k++) if(v[k]==m) a[m-1]++; for(int k=m;k<n;k++){ int cl=col[k-m]; for(int i=0;i<mp[cl].size();i++){ v[mp[cl][i]]--; } cl=col[k]; int x=v[v.size()-1]; v.pop_back(); v.push_front(x); for(int i=0;i<mp[cl].size();i++){ v[(mp[cl][i]+1)%m]++; if(v[(mp[cl][i]+1)%m]==m) a[k]++; } } int ans=0; vector<int> w(n+1,-1); if(a[m-1]==1) w[m-1]=m-1; for(int k=m;k<n;k++){ w[k]=w[k-1]; if(a[k]==1) w[k]=k; } int j=m-1; while(true){ if(w[j]==-1) return -1; ans++; if(j==n-1) break; int i=(j+m)%n; if(w[i]==w[j]) return -1; j=w[i]; } return ans; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 384 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 256 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Execution timed out | 1586 ms | 256 KB | Time limit exceeded |
7 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Execution timed out | 1586 ms | 256 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Execution timed out | 1586 ms | 256 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Execution timed out | 1586 ms | 256 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 0 ms | 256 KB | Output is correct |
2 | Correct | 0 ms | 256 KB | Output is correct |
3 | Correct | 0 ms | 384 KB | Output is correct |
4 | Correct | 0 ms | 256 KB | Output is correct |
5 | Correct | 0 ms | 256 KB | Output is correct |
6 | Correct | 0 ms | 256 KB | Output is correct |
7 | Correct | 0 ms | 256 KB | Output is correct |
8 | Execution timed out | 1586 ms | 256 KB | Time limit exceeded |
9 | Halted | 0 ms | 0 KB | - |