Submission

Status:

PP--------

Subtask/Task Score:

20/100

Score: 20

User: purihorharin

Problemset: ทางเชื่อม

Language: c

Time: 0.158 second

Submitted On: 2026-03-19 21:19:01

#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>

#define modulo 1000000007

int main () {
    int n;
    bool *buf1 = NULL;
    bool *buf2 = NULL;
    scanf("%d", &n);

    for (int i = 0; i < n; i++) {
        int l;
        scanf("%d ", &l);
        buf1 = realloc(buf1, l+1);
        buf2 = realloc(buf2, l+1);
        memset(buf1, 0, l+1);
        memset(buf2, 0, l+1);

        for (int j = 0; j < l; j++) {
            int t = getchar();
            buf1[j] += (t == '#');
        }
        getchar();
        for (int j = 0; j < l; j++) {
            int t = getchar();
            buf2[j] += (t == '#');
        }
        getchar();
        uint64_t count = 2 - buf1[0] - buf2[0];
        for (int j = 0; j < l; j++) {
            if ((buf1[j] && buf2[j+1]) || (buf2[j] && buf1[j+1])) {
                count = 0;
            }
            if (!buf1[j+1] && !buf2[j+1]) {
                count *= 2 - buf1[j] - buf2[j];
                count %= modulo;
            }
            if (count == 0) {
                break;
            }
        }
        printf("%llu\n", count);
    }

    free(buf1);
    free(buf2);
}