Submission
Status:
----------
Subtask/Task Score:
0/100
Score: 0
User: Seng
Problemset: ทางเชื่อม
Language: cpp
Time: 0.293 second
Submitted On: 2026-05-16 10:54:44
#include <bits/stdc++.h>
using namespace std;
#define seng_code ios::sync_with_stdio(0);cin.tie(0);
char arr[7][5005];
int dp[7][5005];
int main(){
seng_code
int m;cin >> m;
while(m--){
int n;cin >> n;
int ans = 0;
memset(dp, sizeof(dp), 0);
for(int i = 1; i <= 2; i++){
for(int j = 1; j <= n; j++){
char x;cin >> x;
arr[i][j] = x;
}
}
dp[1][0] = dp[2][0] = 1;
for(int j = 1; j <= n; j++){
if(arr[1][j] == '#' && arr[2][j] == '.'){
dp[1][j] = 0;
dp[2][j] = dp[2][j-1];
}
else if(arr[1][j] == '.' && arr[2][j] == '#'){
dp[1][j] = dp[1][j-1];
dp[2][j] = 0;
}
else if(arr[1][j] == '#' && arr[2][j] == '#'){
dp[1][j] = dp[2][j] = 0;
}
else{
dp[1][j] = dp[2][j] = dp[1][j-1]+dp[2][j-1];
}
}
cout << dp[1][n]+dp[2][n] << '\n';
}
}