Submission #368344

# Submission time Handle Problem Language Result Execution time Memory
368344 2021-02-19T23:17:45 Z Ahmad_Hasan Vođe (COCI17_vode) C++17
72 / 120
3000 ms 189276 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);*/


    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;
    }

    for(int j=m;j>=0;j--){
        for(int i=n-1;i>=0;i--){
            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<<((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 2 ms 364 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 1004 KB Output is correct
2 Correct 8 ms 492 KB Output is correct
3 Correct 42 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 12 ms 876 KB Output is correct
2 Correct 55 ms 748 KB Output is correct
3 Correct 5 ms 876 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1260 KB Output is correct
2 Correct 80 ms 1536 KB Output is correct
3 Correct 12 ms 1388 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 2108 KB Output is correct
2 Correct 46 ms 1932 KB Output is correct
3 Correct 235 ms 1704 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 6 ms 1900 KB Output is correct
2 Correct 65 ms 2004 KB Output is correct
3 Correct 1 ms 364 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 561 ms 23828 KB Output is correct
2 Execution timed out 3076 ms 26752 KB Time limit exceeded
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3031 ms 56520 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3105 ms 189276 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 3080 ms 187884 KB Time limit exceeded
2 Halted 0 ms 0 KB -