結果
| 問題 |
No.3070 Collecting Coins Speedrun 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-21 22:11:16 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 13 ms / 2,000 ms |
| コード長 | 914 bytes |
| コンパイル時間 | 3,123 ms |
| コンパイル使用メモリ | 278,556 KB |
| 実行使用メモリ | 7,324 KB |
| 最終ジャッジ日時 | 2025-03-21 22:11:21 |
| 合計ジャッジ時間 | 4,463 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 32 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/modint>
using namespace std;
using ll = long long;
using mint = atcoder::modint998244353;
int main() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(nullptr);
int N;
cin >> N;
vector<int> neg, pos;
bool f = false;
for(int i = 0; i < N; i++) {
int x;
cin >> x;
if(x < 0) neg.push_back(x);
else if(x > 0) pos.push_back(x);
else f = true;
}
int K = neg.size();
int L = pos.size();
if(neg.empty() && pos.empty()) {
cout << 1 << endl;
return 0;
}
if(!neg.empty() && !pos.empty()) {
mint ans = mint::raw(2).pow(K - 1) * mint::raw(2).pow(L - 1) * 2 * (f ? 3 : 1);
cout << ans.val() << endl;
} else {
mint ans = mint::raw(2).pow(K + L - 1);
if(f)
{
ans *= 2;
}
cout << ans.val() << endl;
}
}