Submission

Status:

----------

Subtask/Task Score:

0/100

Score: 0

User: hmmm

Problemset: ทางเชื่อม

Language: cpp

Time: 0.352 second

Submitted On: 2026-02-28 22:05:46

#include <bits/stdc++.h>
using namespace std;

const int maxn = 5e3+10;
char c[2][maxn];
long long dp[2][maxn+5];
const long long mod = 1e9+7;

int main() {
    cin.tie(nullptr)->sync_with_stdio(0);
    int q;
    cin >> q;
     
    while(q--){
        int l;
        cin >> l;
        for(int i=0; i<2; i++){
            for(int j=1;j<=l;j++){
            	cin >> c[i][j];
            	dp[0][i]=0;
			}
        }

        
		dp[0][0]=1;
		dp[1][0]=1;        
        for(int j=1; j<=l; j++){
            if(c[0][j] == '.' && c[1][j] == '.') {
                dp[0][j] = (dp[0][j-1]+dp[1][j-1])%mod;
                dp[1][j] = (dp[0][j-1]+dp[1][j-1])%mod;
            }
            else if(c[0][j] == '.' && c[1][j] == '#') {
                dp[0][j] = dp[0][j-1];
                dp[1][j] = 0;
            }
            else if(c[0][j] == '#' && c[1][j] == '.') {
                dp[0][j] = 0;
                dp[1][j] = dp[1][j-1];
            }
            else{
                dp[0][j] = 0;
                dp[1][j] = 0;
            }
//            cout << dp[0][j] << " " << dp[1][j] << "\n";
        }
        cout << (dp[0][l]+dp[1][l]) << '\n';
    }
}