結果
| 問題 |
No.3070 Collecting Coins Speedrun 2
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-03-21 22:59:50 |
| 言語 | D (dmd 2.109.1) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,285 bytes |
| コンパイル時間 | 4,540 ms |
| コンパイル使用メモリ | 163,732 KB |
| 実行使用メモリ | 7,328 KB |
| 最終ジャッジ日時 | 2025-03-21 22:59:56 |
| 合計ジャッジ時間 | 5,897 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 WA * 15 |
ソースコード
import std;
void main () {
int N = readln.chomp.to!int;
auto c = readln.split.to!(int[]);
const long MOD = 998244353;
int minus = 0, plus = 0;
bool zero = false;
foreach (v; c) {
if (v < 0) minus++;
if (0 < v) plus++;
if (v == 0) zero = true;
}
long ans = 0;
long m = mod_pow(2, minus - 1, MOD);
long p = mod_pow(2, plus - 1, MOD);
// plus -> minus
// minus -> plus
// が基本パターンで、0をとるタイミングは各3箇所
ans = 2 * m * p % MOD;
if (zero) {
ans *= 3;
ans %= MOD;
}
writeln(ans);
}
void read (T...) (string S, ref T args) {
import std.conv : to;
import std.array : split;
auto buf = S.split;
foreach (i, ref arg; args) {
arg = buf[i].to!(typeof(arg));
}
}
long mod_pow (long a, long x, const long MOD)
in {
assert(0 <= x, "x must satisfy 0 <= x");
assert(1 <= MOD, "MOD must satisfy 1 <= MOD");
assert(MOD <= int.max, "MOD must satisfy MOD*MOD <= long.max");
}
do {
// normalize
a %= MOD; a += MOD; a %= MOD;
long res = 1L;
long base = a;
while (0 < x) {
if (0 < (x&1)) (res *= base) %= MOD;
(base *= base) %= MOD;
x >>= 1;
}
return res % MOD;
}