結果

問題 No.3070 Collecting Coins Speedrun 2
ユーザー nonon
提出日時 2025-03-21 21:46:47
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 13 ms / 2,000 ms
コード長 657 bytes
コンパイル時間 3,314 ms
コンパイル使用メモリ 274,552 KB
実行使用メモリ 5,888 KB
最終ジャッジ日時 2025-03-21 21:46:56
合計ジャッジ時間 4,704 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 32
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/modint>
using mint = atcoder::modint998244353;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    if (N == 1) {
        cout << 1 << endl;
        return 0;
    }
    int pos = 0, neg = 0, zero = 0;
    for (int i = 0; i < N; i++) {
        int x;
        cin >> x;
        (x > 0 ? pos : x < 0 ? neg : zero)++;
    }
    mint ans = 1;
    if (pos) ans *= mint(2).pow(pos - 1);
    if (neg) ans *= mint(2).pow(neg - 1);
    if (pos > 0 && neg > 0) ans *= 2;
    if (zero > 0) ans *= (pos > 0 && neg > 0 ? 3 : 2);
    cout << ans.val() << endl;
}
0