标签:name src str sample span scoi2009 std put strong
r=((i-1)*m)+j;
if (j!=1)
f[r][k][0]=max(f[r-1][k][0],f[r-1][k-1][1]),
f[r][k][1]=max(f[r-1][k][1],f[r-1][k-1][0]);
else
f[r][k][0]=max(f[r-1][k-1][0],f[r-1][k-1][1]),
f[r][k][1]=max(f[r-1][k-1][1],f[r-1][k-1][0]);
if (s[j-1]==‘0‘) f[r][k][0]++;
else f[r][k][1]++;
1 #include <iostream> 2 using namespace std; 3 int f[2501][2501][2],r; 4 int main() 5 { 6 int n,m,t; 7 cin>>n>>m>>t; 8 string s; 9 for (int i=1;i<=n;i++) 10 { 11 cin>>s; 12 for (int j=1;j<=m;j++) 13 for (int k=1;k<=t;k++) 14 { 15 r=((i-1)*m)+j; 16 if (j!=1) 17 f[r][k][0]=max(f[r-1][k][0],f[r-1][k-1][1]), 18 f[r][k][1]=max(f[r-1][k][1],f[r-1][k-1][0]); 19 else 20 f[r][k][0]=max(f[r-1][k-1][0],f[r-1][k-1][1]), 21 f[r][k][1]=max(f[r-1][k-1][1],f[r-1][k-1][0]); 22 if (s[j-1]==‘0‘) f[r][k][0]++; 23 else f[r][k][1]++; 24 25 } 26 } 27 cout<<max(f[r][t][1],f[r][t][0]); 28 }
标签:name src str sample span scoi2009 std put strong
原文地址:https://www.cnblogs.com/zjzjzj/p/11330409.html