結果

問題 No.1239 Multiplication -2
ユーザー りあんりあん
提出日時 2020-09-05 10:52:04
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 932 bytes
コンパイル時間 2,278 ms
コンパイル使用メモリ 201,524 KB
実行使用メモリ 10,080 KB
最終ジャッジ日時 2023-08-18 16:08:15
合計ジャッジ時間 6,519 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
10,080 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 2 ms
4,384 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,376 KB
testcase_08 AC 1 ms
4,384 KB
testcase_09 AC 1 ms
4,380 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 8 ms
4,380 KB
testcase_16 AC 12 ms
4,384 KB
testcase_17 TLE -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
const int M = 998244353;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> a(n);
    vector<long long> pw(n + 1);
    pw[0] = 1;
    int inv = (M + 1) / 2;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        pw[i + 1] = pw[i] * inv % M;
    }
    long long ans = 0;
    for (int i = 0; i < n; ++i) {
        if (abs(a[i]) < 2) continue;
        int al = 1;
        for (int l = i; l >= 0; --l) {
            if (l < i) al *= a[l];
            if (abs(al) != 1) break;
            int ar = 1;
            for (int r = i; r < n; ++r) {
                if (i < r) ar *= a[r];
                if (abs(ar) != 1) break;
                if (a[i] * al * ar == -2) {
                    ans = (ans + pw[r - l + 2 - (l == 0) - (r == n - 1)]) % M;
                }
            }
        }
    }
    cout << ans << '\n';
    return 0;
}
0