답안 #648493

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
648493 2022-10-06T17:54:16 Z inksamurai Vođe (COCI17_vode) C++17
120 / 120
497 ms 94728 KB
#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)<<" ";
	}
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 320 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 596 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 2 ms 596 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 468 KB Output is correct
2 Correct 2 ms 468 KB Output is correct
3 Correct 2 ms 468 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 724 KB Output is correct
2 Correct 3 ms 852 KB Output is correct
3 Correct 3 ms 852 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 1108 KB Output is correct
2 Correct 3 ms 980 KB Output is correct
3 Correct 2 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 1 ms 212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 54 ms 11936 KB Output is correct
2 Correct 59 ms 13500 KB Output is correct
3 Correct 441 ms 86316 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 141 ms 28372 KB Output is correct
2 Correct 395 ms 77196 KB Output is correct
3 Correct 154 ms 30036 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 497 ms 94728 KB Output is correct
2 Correct 5 ms 2388 KB Output is correct
3 Correct 3 ms 1476 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 476 ms 94140 KB Output is correct
2 Correct 442 ms 84040 KB Output is correct
3 Correct 475 ms 93268 KB Output is correct