結果

問題 No.2250 Split Permutation
ユーザー otoshigootoshigo
提出日時 2023-03-17 22:25:44
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 69 ms / 3,000 ms
コード長 1,118 bytes
コンパイル時間 3,433 ms
コンパイル使用メモリ 165,136 KB
実行使用メモリ 7,968 KB
最終ジャッジ日時 2023-10-18 15:22:53
合計ジャッジ時間 5,690 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 2 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,348 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 2 ms
4,348 KB
testcase_14 AC 2 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 2 ms
4,348 KB
testcase_18 AC 69 ms
7,968 KB
testcase_19 AC 62 ms
7,356 KB
testcase_20 AC 55 ms
7,012 KB
testcase_21 AC 33 ms
5,752 KB
testcase_22 AC 50 ms
6,696 KB
testcase_23 AC 11 ms
4,348 KB
testcase_24 AC 50 ms
6,696 KB
testcase_25 AC 69 ms
7,968 KB
testcase_26 AC 24 ms
5,112 KB
testcase_27 AC 7 ms
4,348 KB
testcase_28 AC 13 ms
4,348 KB
testcase_29 AC 69 ms
7,968 KB
testcase_30 AC 14 ms
4,348 KB
testcase_31 AC 5 ms
4,348 KB
testcase_32 AC 17 ms
4,508 KB
testcase_33 AC 38 ms
6,064 KB
testcase_34 AC 10 ms
4,348 KB
testcase_35 AC 26 ms
5,140 KB
testcase_36 AC 16 ms
4,504 KB
testcase_37 AC 69 ms
7,968 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
#include<algorithm>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll=long long;
using mint=modint998244353;
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin>>n;
    vector<int>p(n);
    vector<pair<int,int>>vp;
    rep(i,n){
        cin>>p[i];
        p[i]--;
        vp.push_back(make_pair(p[i],i));
    }
    sort(all(vp));
    fenwick_tree<int>C(n);
    fenwick_tree<mint>fw(n);
    mint ans=0;
    vector<mint>P(n);
    P[0]=1;
    rep(i,n-1){
        P[i+1]=P[i]*2;
    }
    for(auto[ignore,i]:vp){
        int c=C.sum(i,n);
        mint s=fw.sum(i,n);
        s*=P[i];
        ans+=c*P[n-1]-s;
        fw.add(i,P[n-1-i]);
        C.add(i,1);
    }
    cout<<ans.val()<<"\n";
}
0