Submission #949383

#TimeUsernameProblemLanguageResultExecution timeMemory
949383vjudge1Painting Walls (APIO20_paint)C++17
0 / 100
0 ms512 KiB
#include <bits/stdc++.h> #include "paint.h" //#define int long long #define ff first #define ss second #define pb push_back #define all(x) x.begin(),x.end() using namespace std; int minimumInstructions(int N, int M, int K,vector<int> C,vector<int> A, vector<vector<int>> B) { for(int i=0;i<M;i++){ sort(all(B[i])); } int ans=0; vector <int> used(N); for(int i=0;i<N;i++){ if(!used[i] && i+M-1<N){ for(int y=i;y>=max(0,i-M+1);y--){ bool ok=0; for(int x=0;x<M;x++){ int cnt=0; for(int l=0;l<M;l++){ int pos=(x+l)%M; auto it=lower_bound(all(B[pos]),C[y+l]); if(it!=B[pos].end() && *it==C[y+l])cnt++; else break; } if(cnt==M)ok=1; } if(ok){ for(int j=y;j<y+M;j++)used[j]=1; ans++; break; } } } } if(ans==0)ans=-1; return ans; } /*signed main(){ ios_base::sync_with_stdio(); cin.tie(0);cout.tie(0); int n,m,k; cin>>n>>m>>k; vector <int> c(n),a(m); for(int i=0;i<n;i++)cin>>c[i]; for(int i=0;i<m;i++)cin>>a[i]; vector <vector <int> > b(m); for(int i=0;i<m;i++){ for(int j=0;j<a[i];j++){ int x; cin>>x; b[i].pb(x); } } cout<<minimumInstructions(n,m,k,c,a,b)<<"\n"; }*/ /* 8 3 5 3 3 1 3 4 4 2 2 3 2 2 0 1 2 2 3 3 4 5 4 4 1 0 1 2 2 2 1 1 1 0 1 1 2 3 */
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...