結果
問題 | No.2605 Pickup Parentheses |
ユーザー | Kude |
提出日時 | 2024-01-12 23:17:49 |
言語 | C++23 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 249 ms / 2,000 ms |
コード長 | 2,265 bytes |
コンパイル時間 | 3,186 ms |
コンパイル使用メモリ | 288,240 KB |
実行使用メモリ | 18,780 KB |
最終ジャッジ日時 | 2024-09-30 06:30:34 |
合計ジャッジ時間 | 9,611 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 11 ms
11,340 KB |
testcase_01 | AC | 11 ms
11,336 KB |
testcase_02 | AC | 11 ms
11,340 KB |
testcase_03 | AC | 13 ms
11,336 KB |
testcase_04 | AC | 12 ms
11,460 KB |
testcase_05 | AC | 13 ms
11,468 KB |
testcase_06 | AC | 13 ms
11,464 KB |
testcase_07 | AC | 14 ms
11,336 KB |
testcase_08 | AC | 13 ms
11,464 KB |
testcase_09 | AC | 11 ms
11,208 KB |
testcase_10 | AC | 13 ms
11,336 KB |
testcase_11 | AC | 12 ms
11,464 KB |
testcase_12 | AC | 12 ms
11,204 KB |
testcase_13 | AC | 12 ms
11,336 KB |
testcase_14 | AC | 12 ms
11,340 KB |
testcase_15 | AC | 13 ms
11,336 KB |
testcase_16 | AC | 11 ms
11,340 KB |
testcase_17 | AC | 12 ms
11,464 KB |
testcase_18 | AC | 125 ms
15,848 KB |
testcase_19 | AC | 66 ms
13,724 KB |
testcase_20 | AC | 22 ms
11,596 KB |
testcase_21 | AC | 18 ms
11,724 KB |
testcase_22 | AC | 13 ms
11,456 KB |
testcase_23 | AC | 122 ms
15,188 KB |
testcase_24 | AC | 21 ms
11,592 KB |
testcase_25 | AC | 155 ms
16,792 KB |
testcase_26 | AC | 163 ms
16,608 KB |
testcase_27 | AC | 108 ms
15,652 KB |
testcase_28 | AC | 177 ms
16,824 KB |
testcase_29 | AC | 40 ms
12,364 KB |
testcase_30 | AC | 83 ms
13,908 KB |
testcase_31 | AC | 85 ms
14,128 KB |
testcase_32 | AC | 43 ms
12,528 KB |
testcase_33 | AC | 171 ms
16,620 KB |
testcase_34 | AC | 159 ms
17,064 KB |
testcase_35 | AC | 110 ms
15,372 KB |
testcase_36 | AC | 136 ms
16,392 KB |
testcase_37 | AC | 145 ms
16,776 KB |
testcase_38 | AC | 36 ms
12,832 KB |
testcase_39 | AC | 18 ms
11,716 KB |
testcase_40 | AC | 72 ms
15,404 KB |
testcase_41 | AC | 67 ms
15,172 KB |
testcase_42 | AC | 96 ms
15,776 KB |
testcase_43 | AC | 26 ms
12,164 KB |
testcase_44 | AC | 25 ms
12,316 KB |
testcase_45 | AC | 11 ms
11,208 KB |
testcase_46 | AC | 16 ms
11,720 KB |
testcase_47 | AC | 12 ms
11,336 KB |
testcase_48 | AC | 47 ms
14,668 KB |
testcase_49 | AC | 107 ms
15,884 KB |
testcase_50 | AC | 49 ms
13,536 KB |
testcase_51 | AC | 89 ms
15,780 KB |
testcase_52 | AC | 62 ms
14,108 KB |
testcase_53 | AC | 79 ms
15,944 KB |
testcase_54 | AC | 47 ms
13,684 KB |
testcase_55 | AC | 75 ms
15,532 KB |
testcase_56 | AC | 24 ms
12,100 KB |
testcase_57 | AC | 92 ms
16,288 KB |
testcase_58 | AC | 249 ms
18,780 KB |
testcase_59 | AC | 129 ms
16,128 KB |
testcase_60 | AC | 158 ms
16,628 KB |
testcase_61 | AC | 148 ms
15,712 KB |
testcase_62 | AC | 171 ms
17,056 KB |
testcase_63 | AC | 155 ms
16,512 KB |
testcase_64 | AC | 177 ms
17,524 KB |
testcase_65 | AC | 137 ms
16,364 KB |
testcase_66 | AC | 221 ms
17,752 KB |
testcase_67 | AC | 150 ms
15,764 KB |
testcase_68 | AC | 14 ms
11,208 KB |
testcase_69 | AC | 13 ms
11,212 KB |
testcase_70 | AC | 12 ms
11,336 KB |
コンパイルメッセージ
main.cpp:49:6: warning: '{anonymous}::mint {anonymous}::perm(int, int)' defined but not used [-Wunused-function] 49 | mint perm(int n, int k) { | ^~~~ main.cpp:48:6: warning: '{anonymous}::mint {anonymous}::fact(int)' defined but not used [-Wunused-function] 48 | mint fact(int n) {return Fact[n];} | ^~~~ main.cpp:44:6: warning: '{anonymous}::mint {anonymous}::icomb(int, int)' defined but not used [-Wunused-function] 44 | mint icomb(int n, int k) { | ^~~~~
ソースコード
#include<bits/stdc++.h> namespace { #pragma GCC diagnostic ignored "-Wunused-function" #include<atcoder/all> #pragma GCC diagnostic warning "-Wunused-function" using namespace std; using namespace atcoder; #define rep(i,n) for(int i = 0; i < (int)(n); i++) #define rrep(i,n) for(int i = (int)(n) - 1; i >= 0; i--) #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) template<class T> bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; } template<class T> bool chmin(T& a, const T& b) { if (b < a) { a = b; return true; } else return false; } using ll = long long; using P = pair<int,int>; using VI = vector<int>; using VVI = vector<VI>; using VL = vector<ll>; using VVL = vector<VL>; using mint = modint998244353; constexpr int FACT_SIZE = 1000000; mint Fact[FACT_SIZE + 1]; mint iFact[FACT_SIZE + 1]; const auto fact_init = [] { Fact[0] = mint::raw(1); for(int i = 1; i <= FACT_SIZE; ++i) { Fact[i] = Fact[i-1] * i; } iFact[FACT_SIZE] = Fact[FACT_SIZE].inv(); for(int i = FACT_SIZE; i; --i) { iFact[i-1] = iFact[i] * i; } return false; }(); mint comb(int n, int k) { if (k == 0) return mint::raw(1); assert(n >= 0 && k >= 0); if (k > n) return mint::raw(0); return Fact[n] * iFact[n - k] * iFact[k]; } mint icomb(int n, int k) { return iFact[n] * Fact[n - k] * Fact[k]; } mint fact(int n) {return Fact[n];} mint perm(int n, int k) { assert(0 <= n); return Fact[n] * iFact[n - k]; } mint f(int len) { if (len % 2) return 0; if (len == 0) return 1; int n = len / 2; return comb(2 * n, n) - comb(2 * n, n - 1); } } int main() { ios::sync_with_stdio(false); cin.tie(0); int n, m; cin >> n >> m; queue<vector<mint>> q; q.push({1}); rep(_, m) { int l, r; cin >> l >> r; l--; vector<mint> g(r - l + 1); g[0] = 1; g[r - l] = -f(r - l); q.emplace(move(g)); } while (q.size() >= 2) { auto f = move(q.front()); q.pop(); auto g = move(q.front()); q.pop(); q.emplace(convolution(f, g)); } auto h = move(q.front()); q.pop(); mint ans; for (int i = 0; mint v : h) { ans += f(n - i) * v; // cout << i << ' ' << v.val() << endl; i++; } cout << ans.val() << '\n'; }