Submission #489885

# Submission time Handle Problem Language Result Execution time Memory
489885 2021-11-25T02:46:39 Z robell Vođe (COCI17_vode) C++14
120 / 120
810 ms 192416 KB
/*
Problem: 
Problem Link: 
Notes: 
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef long long ll;
#define pb push_back
#define eb emplace_back
#define countbits __builtin_popcount
#define beg0 __builtin_clz
#define terminal0 __builtin_ctz
#define f first
#define s second
int mod=1e9+7;
inline void rv(int &n){
    n=0;int m=1;char c=getchar_unlocked();
    if (c=='-'){m=-1; c=getchar_unlocked();}
    for (;c>47 && c<58;c=getchar_unlocked()){n=n*(1<<1)+n*(1<<3)+c-48;}
    n*=m;
}
inline void rv(ll &n){
    n=0;int m=1;char c=getchar_unlocked();
    if (c=='-'){m=-1; c=getchar_unlocked();}
    for (;c>47 && c<58;c=getchar_unlocked()){n=n*(1<<1)+n*(1<<3)+c-48;}
    n*=m;
}
inline void rv(double &n){
    n=0;int m=1;char c=getchar_unlocked();
    if (c=='-'){m=-1; c=getchar_unlocked();}
    for (;c>47 && c<58;c=getchar_unlocked()){n=n*(1<<1)+n*(1<<3)+c-48;}
    if (c=='.'){
        double p = 0.1;c=getchar_unlocked();
        for (;c>47 && c<58;c=getchar_unlocked()){n+=((c-48)*p);p/=10;}
    }
    n*=m;
}
inline void rv(float &n){
    n=0;int m=1;char c=getchar_unlocked();
    if (c=='-'){m=-1; c=getchar_unlocked();}
    for (;c>47 && c<58;c=getchar_unlocked()){n=n*(1<<1)+n*(1<<3)+c-48;}
    if (c=='.'){
        double p = 0.1;c=getchar_unlocked();
        for (;c>47 && c<58;c=getchar_unlocked()){n+=((c-48)*p);p/=10;}
    }
    n*=m;
}
inline void rv(string &w){
    w="";char c=getchar_unlocked();
    while (c!=' '&&c!='\n'&&c!=EOF){w+=c;c=getchar_unlocked();}
}
inline void rv(char &c){c=getchar_unlocked();}
template<typename T, typename ...Types>
void rv(T &n, Types&&... args){rv(n);rv(args...);}
void setIO(){
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
}
void setIO(string f){
	freopen((f+".in").c_str(),"r",stdin);
	freopen((f+".out").c_str(),"w",stdout);
	setIO();
}
int N, M, K, cn[5000][5001];
int pl[5000], dp[5000][5000];
int main() {
	setIO();cin >> N >> M >> K;
    for (int i=0;i<N;i++) cin >> pl[i];
    for (int i=0;i<N;i++){dp[i][M-1]=!pl[i];cn[i][M]=0;cn[i][M-1]=!pl[i];}
	for (int i = M-2; i >= 0; i--){
		for (int j = 0; j < N; j++){
			int s=i+1,f=min(M,i+K+1),il=f-s,nv=(j+1)%N,itn=cn[nv][s]-cn[nv][f];
			if(pl[j]){
				dp[j][i]=true;
				if(itn==0){
					dp[j][i]=false;
				}
			}else{
				dp[j][i]=false;
				if(itn==il){
					dp[j][i]=true;
				}
			}
			cn[j][i]=cn[j][i+1]+dp[j][i];
		}
	}
	for (int i=0;i<N;i++){
		cout << dp[i][0] << " ";
	}
    cout << "\n";
}

Compilation message

vode.cpp: In function 'void setIO(std::string)':
vode.cpp:65:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   65 |  freopen((f+".in").c_str(),"r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
vode.cpp:66:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   66 |  freopen((f+".out").c_str(),"w",stdout);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 0 ms 332 KB Output is correct
2 Correct 1 ms 972 KB Output is correct
3 Correct 1 ms 720 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2252 KB Output is correct
2 Correct 1 ms 1232 KB Output is correct
3 Correct 1 ms 2256 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2636 KB Output is correct
2 Correct 1 ms 2384 KB Output is correct
3 Correct 2 ms 2752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 3788 KB Output is correct
2 Correct 3 ms 4432 KB Output is correct
3 Correct 3 ms 4176 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 5708 KB Output is correct
2 Correct 4 ms 5308 KB Output is correct
3 Correct 3 ms 4932 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 4940 KB Output is correct
2 Correct 3 ms 5200 KB Output is correct
3 Correct 0 ms 336 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 96 ms 37884 KB Output is correct
2 Correct 112 ms 41116 KB Output is correct
3 Correct 654 ms 188772 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 208 ms 76132 KB Output is correct
2 Correct 584 ms 188372 KB Output is correct
3 Correct 231 ms 81712 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 734 ms 190072 KB Output is correct
2 Correct 4 ms 4816 KB Output is correct
3 Correct 3 ms 2896 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 715 ms 191704 KB Output is correct
2 Correct 599 ms 192012 KB Output is correct
3 Correct 810 ms 192416 KB Output is correct