Submission #648493

#TimeUsernameProblemLanguageResultExecution timeMemory
648493inksamuraiVođe (COCI17_vode)C++17
120 / 120
497 ms94728 KiB
#include <bits/stdc++.h> using namespace std; #define rep(i,n) for(int i=0;i<n;i++) #define rng(i,c,n) for(int i=c;i<n;i++) #define per(i,n) for(int i=n-1;i>=0;i--) #define fi first #define se second #define pb push_back #define sz(a) (int)a.size() #define vec(...) vector<__VA_ARGS__> #define _3Rz7lEu ios::sync_with_stdio(0),cin.tie(0) typedef long long ll; using pii=pair<int,int>; using vi=vector<int>; void print(){cout<<'\n';} template<class h,class...t> void print(const h&v,const t&...u){cout<<v<<' ',print(u...);} // e signed main(){ _3Rz7lEu; int n,m,k; cin>>n>>m>>k; vi a(n); rep(i,n){ cin>>a[i]; } vec(vi) dp(n,vi(m)); vec(pii) pd(n,pii(m+k+1,m+k+1)); // (0,1) per(j,m){ if(j==m-1){ rep(i,n){ dp[i][j]=0; pd[i].fi=j; } }else{ vec(pii) npd; npd=pd; rep(i,n){ int ni=(i+1)%n; int v=a[i]; int u=a[ni]; // if(i==3 and j==0) print(v,u,pd[]); if(v==u){ // i want to know if there is at least one dp[ni][nj] with value 1 // where nj is in range [j+1 ... j+k] int nxt=pd[ni].se; if(nxt-j<=k) dp[i][j]=1; else dp[i][j]=0; }else{ int nxt=pd[ni].fi; if(nxt-j<=k) dp[i][j]=1; else dp[i][j]=0; } } rep(i,n){ if(dp[i][j]){ npd[i].se=j; }else{ npd[i].fi=j; } } pd.swap(npd); } // if(j<=k){ // cout<<dp[4][j]<<" "; // } } rep(i,n){ int val=dp[i][0]; cout<<(val^a[i]^1)<<" "; } }
#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...
#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...