#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));
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(v==u){
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);
}
}
rep(i,n){
int val=dp[i][0];
cout<<(val^a[i]^1)<<" ";
}
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
212 KB |
Output is correct |
2 |
Correct |
0 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
596 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
596 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
468 KB |
Output is correct |
2 |
Correct |
1 ms |
468 KB |
Output is correct |
3 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
724 KB |
Output is correct |
2 |
Correct |
2 ms |
852 KB |
Output is correct |
3 |
Correct |
2 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
1108 KB |
Output is correct |
2 |
Correct |
2 ms |
980 KB |
Output is correct |
3 |
Correct |
3 ms |
852 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
3 ms |
980 KB |
Output is correct |
2 |
Correct |
3 ms |
1108 KB |
Output is correct |
3 |
Correct |
0 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
65 ms |
11988 KB |
Output is correct |
2 |
Correct |
63 ms |
13396 KB |
Output is correct |
3 |
Correct |
440 ms |
86308 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
138 ms |
28404 KB |
Output is correct |
2 |
Correct |
448 ms |
77180 KB |
Output is correct |
3 |
Correct |
159 ms |
30036 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
496 ms |
94712 KB |
Output is correct |
2 |
Correct |
5 ms |
2388 KB |
Output is correct |
3 |
Correct |
3 ms |
1492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
485 ms |
94120 KB |
Output is correct |
2 |
Correct |
442 ms |
83940 KB |
Output is correct |
3 |
Correct |
478 ms |
93260 KB |
Output is correct |