結果

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

ソースコード

diff #

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

typedef long long ll;

using mint = modint998244353;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    int n;
    cin >> n;
    int pl = 0, mi = 0, ze = 0;
    rep(i, 0, n) {
        int x;
        cin >> x;
        if (x > 0)
            pl++;
        else if (x < 0)
            mi++;
        else
            ze++;
    }
    if (pl == 0 && mi == 0) {
        cout << 1 << endl;
        return 0;
    }
    if (pl > mi)
        swap(pl, mi);
    if (pl == 0) {
        cout << pow_mod(2, mi + ze - 1, 998244353) << endl;
        return 0;
    }
    mint ans = 1;
    if (pl && mi && ze) {
        ans *= 3;
    }
    if (pl)
        ans *= pow_mod(2, pl - 1, 998244353);
    if (mi)
        ans *= pow_mod(2, mi - 1, 998244353);
    if (pl && mi)
        ans *= 2;
    cout << ans.val() << endl;
}
0