結果

問題 No.663 セルオートマトンの逆操作
コンテスト
ユーザー zelda_master
提出日時 2026-11-22 16:38:46
言語 C++14
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++14 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
WA  
実行時間 -
コード長 1,138 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 383 ms
コンパイル使用メモリ 82,548 KB
実行使用メモリ 9,928 KB
最終ジャッジ日時 2026-11-22 16:38:50
合計ジャッジ時間 3,537 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19 WA * 8
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <iostream>
#include <vector>
#include <cstdio>

using namespace std;

const int N = 2010, MOD = 1000000007;

int n, a[N], ans;

int main() {
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i) {
        scanf("%d", &a[i]);
    }

    for (int mask = 0; mask < (1 << n); ++mask) {
        bool ok = true;
        for (int i = 0; i < n; ++i) {
            int x, y, z;
            if (i == 0) {
                x = mask >> (n - 1) & 1;
                y = mask >> i & 1;
                z = mask >> (i + 1) & 1;
            } else if (i == n - 1) {
                x = mask >> (i - 1) & 1;
                y = mask >> i & 1;
                z = mask >> 0 & 1;
            } else {
                x = mask >> (i - 1) & 1;
                y = mask >> i & 1;
                z = mask >> (i + 1) & 1;
            }
            int val;
            if ((x == 1 && y == 1 && z == 1) || (y == 0 && z == 0)) val = 0;
            else val = 1;
            if (a[i + 1] != val) {
                ok = false;
                break;
            }
        }
        (ans += ok) %= MOD;
    }

    printf("%d\n", ans % MOD);

    return 0;
}
0