水题-洛谷P2543 [AHOI2004]奇怪的字符串

https://www.luogu.org/problem/show?pid=2543
水题;
然后这个要滚存;
我一开始在想怎么去把i,j都滚掉;
后来jzq说只要滚i就好啦;
然后数组位置反了;
然后c=!c写错位子了;
场面一度尴尬;
水题翻车;

#include<iostream>
#include<cstdio>
#include<cstring>
#define Ll long long
using namespace std;
string a,b;
int n,m;
bool c;
int f[2][10001];
int main()
{
    cin>>a>>b;
    n=a.length();
    m=b.length();
    a=' '+a;
    b=' '+b;
    for(int i=1;i<=n;i++){
        c=!c;
        for(int j=1;j<=m;j++){
            if(a[i]!=b[j])
                f[c][j]=max(f[!c][j],f[c][j-1]);
            else
                f[c][j]=f[!c][j-1]+1;
        }}
    cout<<f[c][m];
}
posted @ 2017-03-17 08:25  largecube233  阅读(89)  评论(0编辑  收藏  举报