Submission

Status:

PPPPPPPPPP

Subtask/Task Score:

100/100

Score: 100

User: patty

Problemset: ทางเชื่อม

Language: cpp

Time: 0.326 second

Submitted On: 2026-03-20 13:53:22

#include <bits/stdc++.h>
using namespace std;
vector<vector<char>> lan(5, vector<char> (5005));
vector<vector<long long>> dp(5,vector<long long> (5005,0));
const int inf=1e9+7;
int main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin >> n;
	for(int i=0;i<n;i++) {
		int l;
		cin >> l;
		for(int j=1;j<3;j++) {
			for(int k=1;k<=l;k++) {
				cin >> lan[j][k];
			}
		}
		for(int j=1;j<3;j++) {
			for(int k=1;k<=l;k++) {
				dp[j][k] = 0;
			}
		}
		dp[1][0] = 1;
		dp[2][0] = 1;
		for(int k=1;k<=l;k++) {
			if(lan[1][k]=='.' && lan[2][k]=='#') {
				dp[1][k] = dp[1][k-1];
			} else if(lan[2][k]=='.' && lan[1][k]=='#') dp[2][k] = dp[2][k-1];
			else {
				dp[1][k] = (dp[1][k-1] + dp[2][k-1])%inf;
				dp[2][k] = (dp[1][k-1] + dp[2][k-1])%inf;
			}
		}
		cout << (dp[1][l]+dp[2][l])%inf << '\n';
	}
}