Submission #369201

# Submission time Handle Problem Language Result Execution time Memory
369201 2021-02-20T21:58:42 Z Ahmad_Hasan Vođe (COCI17_vode) C++17
96 / 120
1629 ms 524292 KB
#include <bits/stdc++.h>
#define int long long
/**
     ||||||||||       |||||     |||||    ||||||||||
    |||||||||||||     |||||     |||||  |||||
   ||||     ||||||    |||||     |||||  |||||
  |||||||||||||||||   |||||||||||||||    ||||||||||
 |||||||||||||||||||  |||||||||||||||           |||||
 |||||         |||||  |||||     |||||           |||||
 |||||         |||||  |||||     |||||    ||||||||||
AHMED;HASSAN;SAEED;
*/

using namespace std;



int32_t main()
{
    /**freopen("movie.in","r",stdin);
    freopen("movie.out","w",stdout);*/
    ios_base::sync_with_stdio(0);
    cin.tie(0);      cout.tie(0);


    int n,m,k;
    cin>>n>>m>>k;

    vector<int>v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
    }
    vector<vector<int> >dp(n+5,vector<int>(m+5,-2));

    for(int i=0;i<n;i++){
        dp[i][m]=0;
        dp[i][0]=-1;
    }

    int cntr[n+5][m+5][2];
    memset(cntr,0,sizeof(cntr));
    for(int i=0;i<n;i++)
        cntr[i][m][0]=1;

    for(int j=m-1;j>=0;j--){
        for(int i=n-1;i>=0;i--){

            if(j==0){
                if(cntr[i][j+1][1])
                    dp[i][j]=1;
                else
                    dp[i][j]=0;
            }
            else{
                if(v[i]==v[(i+1)%n]){
                    if(cntr[(i+1)%n][j+1][1])
                        dp[i][j]=1;
                    else
                        dp[i][j]=0;
                }
                else{
                    if(cntr[(i+1)%n][j+1][1])
                        dp[i][j]=0;
                    else
                        dp[i][j]=1;
                }
            }
            cntr[i][j][0]=cntr[i][j+1][0];
            cntr[i][j][1]=cntr[i][j+1][1];
            cntr[i][j][dp[i][j]]++;
            if(j+k<=m){
                cntr[i][j][dp[i][j+k]]--;

            }
            ///cout<<i<<' '<<j<<' '<<cntr[i][j][0]<<'\n';


            /**
            for(int z=1;z<=k;z++){
                if(z+j<=m){
                    if(j==0){
                        dp[i][j]=max(dp[i][j],dp[i][z]);
                    }
                    else{
                        if(v[i]==v[(i+1)%n])
                            dp[i][j]=max(dp[i][j],dp[(i+1)%n][j+z]);
                        else{
                            if(dp[i][j]==-2)
                                dp[i][j]=2;
                            dp[i][j]=min(dp[i][j],1-dp[(i+1)%n][j+z]);
                        }
                    }
                }

            }*/
        }
    }
/**
    for(int i=0;i<n;i++){
        cout<<'#';
        for(int j=0;j<=m;j++){
            cout<<dp[i][j]<<' ';
        }
        cout<<'\n';
    }
    for(int i=0;i<n;i++){
        cout<<'#';
        for(int j=0;j<=m;j++){
            cout<<cntr[i][j][0]<<'&'<<cntr[i][j][1]<<' ';
        }
        cout<<'\n';
    }
*/

    for(int i=0;i<n;i++)
        cout<<((dp[i][0]==1)?v[i]:!v[i])<<' ';



    return 0;
}



/**
6 20 5
1 0 0 1 1 0


*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 364 KB Output is correct
2 Correct 1 ms 492 KB Output is correct
3 Correct 1 ms 512 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2284 KB Output is correct
2 Correct 1 ms 748 KB Output is correct
3 Correct 2 ms 2156 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 1920 KB Output is correct
2 Correct 2 ms 1772 KB Output is correct
3 Correct 3 ms 1928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 4 ms 3180 KB Output is correct
2 Correct 4 ms 3692 KB Output is correct
3 Correct 4 ms 3564 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 5484 KB Output is correct
2 Correct 6 ms 4972 KB Output is correct
3 Correct 4 ms 4204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 4972 KB Output is correct
2 Correct 6 ms 5228 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 173 ms 70508 KB Output is correct
2 Correct 227 ms 79596 KB Output is correct
3 Correct 1629 ms 516228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 503 ms 168860 KB Output is correct
2 Correct 1468 ms 461444 KB Output is correct
3 Correct 481 ms 178668 KB Output is correct
# Verdict Execution time Memory Grader output
1 Runtime error 265 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 251 ms 524292 KB Execution killed with signal 9
2 Halted 0 ms 0 KB -