Submission #318701

# Submission time Handle Problem Language Result Execution time Memory
318701 2020-11-02T23:03:55 Z Marlov Vođe (COCI17_vode) C++14
0 / 120
1187 ms 191860 KB
/*
Code by @marlov       
*/
#include <iostream>
#include <fstream>
#include <string>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <utility>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <stack>
#include <queue>
#include <iterator>
using namespace std;
typedef long long ll;
typedef pair<int,int> pi;

#define maxV 5005

int N,M,K;
int arr[maxV];
int dp[maxV][maxV];
int psum[maxV][maxV];
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>N>>M>>K;
	for(int i=0;i<N;i++){
		fill(dp[i],dp[i]+maxV,-1);
	}
	for(int i=0;i<N;i++){
		cin>>arr[i];
		dp[i][M]=1-arr[i];
		psum[i][M]=1-arr[i];
	}
	for(int j=M-1;j>=0;j--){
		for(int i=0;i<N;i++){
			int pvs=psum[(i+1)%N][j+1]-psum[(i+1)%N][min(M+1,j+1+K)];
			if(pvs==0&&arr[i]==1){
				dp[i][j]=0;
			}else if(pvs==K&&arr[i]==0){
				dp[i][j]=1;
			}else{
				dp[i][j]=arr[i];
			}
		}
		for(int i=0;i<N;i++){
			psum[i][j]=dp[i][j]+psum[i][j+1];
		}
	}
	for(int i=0;i<N;i++){
		cout<<dp[(i+N-1)%N][0]<<" ";
	}
    return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1,n=0?)
	* do smth instead of nothing and stay organized
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 492 KB Output is correct
2 Incorrect 2 ms 2156 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 4716 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 5 ms 6124 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 7 ms 8300 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 10 ms 12140 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 10604 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 158 ms 54372 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 375 ms 87408 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1187 ms 190336 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1167 ms 191860 KB Output isn't correct
2 Halted 0 ms 0 KB -