結果
問題 | No.2250 Split Permutation |
ユーザー |
|
提出日時 | 2023-03-21 14:18:12 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 167 ms / 3,000 ms |
コード長 | 538 bytes |
コンパイル時間 | 5,659 ms |
コンパイル使用メモリ | 311,592 KB |
実行使用メモリ | 8,272 KB |
最終ジャッジ日時 | 2024-09-18 14:21:59 |
合計ジャッジ時間 | 7,559 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 35 |
ソースコード
#include <bits/stdc++.h>#include <atcoder/all>using namespace std;using Mint = atcoder::modint998244353;Mint add(Mint a, Mint b) { return a + b; }Mint zero() { return 0; }using Seg = atcoder::segtree<Mint, add, zero>;int main(){int N;cin >> N;Seg seg(N), seg2(N);Mint ans = 0;for (int i = 0; i < N; ++i){int p;cin >> p;--p;ans += seg2.prod(p + 1, N) * Mint(2).pow(N - 1);ans -= seg.prod(p + 1, N) * Mint(2).pow(N - 1 - i);seg.set(p, Mint(2).pow(i));seg2.set(p, 1);}cout << ans.val() << endl;}