Submission

Status:

PP-------P

Subtask/Task Score:

30/100

Score: 30

User: devilpoohs

Problemset: ทางเชื่อม

Language: cpp

Time: 0.355 second

Submitted On: 2026-03-09 15:30:00

#include<bits/stdc++.h>
using namespace std;
const int mod=1e9+7;
#define int long long
void sol(){
    int n;
    cin>>n;
    char ch[2][n+1];
    int dp[2][n+1];
    for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
            cin>>ch[i][j];
        }
    }
    ch[0][n]='.';
    ch[1][n]='.';
    memset(dp,0,sizeof(dp));
    if(ch[0][0]!='#') dp[0][0]=1;
    if(ch[1][0]!='#') dp[1][0]=1;
    for(int j=1;j<=n;j++){
        if(ch[0][j-1]!='#' and ch[0][j]!='#')
            dp[0][j]=dp[0][j-1]+dp[1][j-1];
        dp[0][j]%=mod;
        if(ch[1][j-1]!='#' and ch[1][j]!='#')        
            dp[1][j]=dp[0][j-1]+dp[1][j-1];
        dp[1][j]%=mod;
    }
    // for(int i=0;i<2;i++){
    //     for(int j=0;j<=n;j++){
    //         cout<<dp[i][j]<<' ';
    //     }
    //     cout<<'\n';
    // }
    cout<<(dp[0][n]+dp[1][n])%mod<<'\n';
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;
    cin>>t;
    while(t--){
        sol();
    }
}
/*
3
4
.#..
.#..
4
.#..
...#
2
#.
..

*/