結果

問題 No.663 セルオートマトンの逆操作
コンテスト
ユーザー V_Melville
提出日時 2026-11-20 23:01:17
言語 C++23
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++23 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 2 ms / 2,000 ms
+ 5µs
コード長 850 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 4,936 ms
コンパイル使用メモリ 382,024 KB
実行使用メモリ 9,868 KB
最終ジャッジ日時 2026-11-20 23:01:33
合計ジャッジ時間 6,544 ms
ジャッジサーバーID
(参考情報)
judge2_0 / judge4_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;
using mint = modint1000000007;

int f(int a, int b, int c) {
    return (a and b and c) or (!b and !c) ? 0 : 1;
}

int main() {
    int n;
    cin >> n;

    vector<int> e(n);
    rep(i, n) cin >> e[i];

    mint ans;
    rep(s, 4) {
        vector<mint> dp(4);
        dp[s] = 1;
        rep(i, n) {
            vector<mint> old(4);
            dp.swap(old);
            
            rep(t, 4) {
                int a = t/2, b = t%2;
                rep(c, 2) {
                    if (f(a, b, c) == e[i]) {
                        dp[b*2+c] += old[t];
                    }
                }
            }
        }
        
        ans += dp[s];
    }

    cout << ans.val() << '\n';
    
    return 0;
}
0