結果

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

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/modint>

using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);

    int N, c, ne=0, po=0, zero=0;
    cin >> N;
    for (int i=0; i<N; i++){
        cin >> c;
        if (c < 0) ne++;
        else if (c > 0) po++;
        else zero++;
    }

    if (N == 1 && zero == 1){
        cout << 1 << endl;
        return 0;
    }

    mint ans=1;
    if (ne) ans *= mint(2).pow(ne-1);
    if (po) ans *= mint(2).pow(po-1);

    if (ne && po) ans *= 2;
    if (zero){
        if (ne && po) ans *= 3;
        else ans *= 2;
    }

    cout << ans.val() << endl;

    return 0;
}
0