跳到正文

题解

题解 AT2697 【[ARC081B] Coloring Dominoes】

C C A约 1 分钟
原文
文章信息与版本

文章信息

发布
2020年11月29日
收录
2026年1月12日
更新
2026年11月16日
篇幅
约 1 分钟

版本

  1. v1当前

发这篇题解只是为了分享一个精简的代码实现( 411B\rm 411B ,在保持代码可读性的同时比第二短的代码短了 13\frac{1}{3} ),思路大体与官方题解相同 。

Code\LARGE Code
C++
#include<bits/stdc++.h>
using namespace std;
int n, i, ans; char a[60], b[60];
int main () {
    scanf("%d%s%s", &n, a, b);
    a[0] == b[0] ? (ans = 3, i = 1) : (ans = 6, i = 2);
    while (i < n) {
        if(a[i - 1] == b[i - 1]) ans = ans * 2 % 1000000007;
        else if(a[i] != b[i]) ans = ans * 3ll % 1000000007;
        i += 2 - (a[i] == b[i]);
    }
    printf("%d", ans);
    return 0;
}
原文