Submission #236773

#TimeUsernameProblemLanguageResultExecution timeMemory
236773topovikVođe (COCI17_vode)C++14
0 / 120
3080 ms96380 KiB
#include <bits/stdc++.h> #define f first #define s second #define pb push_back using namespace std; typedef long long ll; typedef long double ld; const ll oo = 1e9+7; const ll N = 5000+2; int dp[N][N]; int b[N]; int n,m,k; int Rec(int x,int y) { if (dp[x][y]<oo) return dp[x][y]; int nx=(x+1)%n; bool g0=0,g1=0; for (int i=1; i<=k && i+y<=m; i++) { int c=Rec(nx,i+y); g0=g0||(c==0); g1=g1||(c==1); } if (b[x]==b[nx]) return dp[x][y]=g1; else return dp[x][y]=g0; } int main() { cin>>n>>m>>k; for (int i=0; i<n; i++) cin>>b[i]; for (int i=0; i<n; i++) for (int j=1; j<=m; j++) dp[i][j]=oo; for (int i=0; i<n; i++) dp[i][m]=1; for (int i=0; i<n; i++) { bool g=0; for (int j=1; j<=min(k,m); j++) g=g||Rec(i,j); cout<<(g^b[i]^1)<<" "; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...