結果
問題 |
No.3070 Collecting Coins Speedrun 2
|
ユーザー |
![]() |
提出日時 | 2025-05-10 05:10:20 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,298 bytes |
コンパイル時間 | 1,986 ms |
コンパイル使用メモリ | 195,804 KB |
実行使用メモリ | 7,848 KB |
最終ジャッジ日時 | 2025-05-10 05:10:24 |
合計ジャッジ時間 | 3,655 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 WA * 2 |
other | AC * 20 WA * 12 |
コンパイルメッセージ
main.cpp: In function ‘void fileIO(std::string)’: main.cpp:5:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 5 | freopen((s + ".in").c_str(), "r", stdin); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ main.cpp:6:12: warning: ignoring return value of ‘FILE* freopen(const char*, const char*, FILE*)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 6 | freopen((s + ".out").c_str(), "w", stdout); | ~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ソースコード
#include <bits/stdc++.h> using namespace std; void fileIO(string s) { freopen((s + ".in").c_str(), "r", stdin); freopen((s + ".out").c_str(), "w", stdout); } using i64 = long long; const int N = 1e5 + 10, P = 998244353; int qpow(int b, int k) { int ret = 1; while(k > 0) { if(k & 1) ret = ret * (i64)b % P; b = (i64)b * b % P; k >>= 1; } return ret; } int inv[N], fact[N], invFact[N]; int C(int n, int m) { if(m > n || m < 0) return 0; return fact[n] * (i64)invFact[m] % P * invFact[n - m] % P; } int main() { ios::sync_with_stdio(false); cin.tie(0); inv[1] = fact[0] = fact[1] = invFact[0] = invFact[1] = 1; for(int i = 2; i < N; i ++) { inv[i] = (P - P / i) * (i64)inv[P % i] % P; fact[i] = fact[i - 1] * (i64)i % P; invFact[i] = invFact[i - 1] * (i64)inv[i] % P; } int n; cin >> n; int a = 0, b = 0, c = 0; for(int i = 1, x; i <= n; i ++) { cin >> x; if(x < 0) a ++; if(x > 0) b ++; else c ++; } int ans = 1; if(a > 0) ans = ans * (i64)qpow(2, a - 1) % P; if(b > 0) ans = ans * (i64)qpow(2, b - 1) % P; if(a > 0 && b > 0) (ans *= 2) %= P; if(c) ans = ans * (1ll + (a > 0) + (b > 0)) % P; cout << ans << "\n"; }