General
 
 
# Author Problem Lang Verdict Time Memory Sent Judged  
230662478 Practice:
racccccoon
1499E - 8 C++14 (GCC 6-32) Accepted 108 ms 31948 KB 2023-10-31 13:50:30 2023-10-31 13:50:30
→ Source
// LUOGU_RID: 132630729
#include<bits/stdc++.h>
using namespace std;
const int mod=998244353;
const int N=1010;
int n,m;
char s[N],t[N];
int dp[N][N][2][4];
// s 串计算到 i;t 串计算到 j;z 的上一位来自 s/t;已经选了 s/t(00,01,10,11);
int main()
{
    scanf("%s%s",s+1,t+1);
    n=strlen(s+1),m=strlen(t+1);
    for(int i=0;i<=n;i++)
    for(int j=0;j<=m;j++)
    {
        if(i<n)
            (dp[i+1][j][0][1]+=1)%=mod;
        if(j<m)
            (dp[i][j+1][1][2]+=1)%=mod;
        for(int k=0;k<4;k++)
        {
            if(i<n&&s[i]!=s[i+1])
                (dp[i+1][j][0][k|1]+=dp[i][j][0][k])%=mod;
            if(i<n&&t[j]!=s[i+1])
                (dp[i+1][j][0][k|1]+=dp[i][j][1][k])%=mod;
            if(j<m&&s[i]!=t[j+1])
                (dp[i][j+1][1][k|2]+=dp[i][j][0][k])%=mod;
            if(j<m&&t[j]!=t[j+1])
                (dp[i][j+1][1][k|2]+=dp[i][j][1][k])%=mod;
        }
    }
    int ans=0;
    for(int i=1;i<=n;i++)
    for(int j=1;j<=m;j++)
    {
        ans+=dp[i][j][0][3];ans%=mod;
        ans+=dp[i][j][1][3];ans%=mod;
    }
    printf("%d\n",ans);
    return 0;
}
?
Time: ? ms, memory: ? KB
Verdict: ?
Input
?
Participant's output
?
Jury's answer
?
Checker comment
?
Diagnostics
?
Click to see test details