結果

問題 No.2250 Split Permutation
ユーザー bayashikobayashiko
提出日時 2023-03-06 20:39:37
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 2,396 bytes
コンパイル時間 5,175 ms
コンパイル使用メモリ 282,780 KB
実行使用メモリ 5,272 KB
最終ジャッジ日時 2023-10-18 11:04:27
合計ジャッジ時間 9,972 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 12 ms
4,348 KB
testcase_04 AC 3 ms
4,348 KB
testcase_05 AC 7 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 12 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 12 ms
4,348 KB
testcase_14 AC 3 ms
4,348 KB
testcase_15 AC 2 ms
4,348 KB
testcase_16 AC 2 ms
4,348 KB
testcase_17 AC 7 ms
4,348 KB
testcase_18 WA -
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
//#pragma GCC target("avx2")
#pragma GCC optimize("unroll-loops")
using namespace std;
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
//#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define MINF (lint)(2e18)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define flc(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
#define all(x) x.begin(),x.end()
//#define vec vector<lint>
#define nep(x) next_permutation(all(x))
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=3e5+5;
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//vector<int> bucket[MAX_N/1000];
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
//typedef __int128_t llint;
#include<atcoder/all>
using namespace atcoder;

using mint=modint998244353;
mint op(mint a,mint b){
    return a+b;
}
mint e(){
    return 0;
}

int main(void){
    lint N;
    cin >> N;
    lint P[N];
    rep(i,N) cin >> P[i],P[i]--;
    mint ans=0;
    rep(i,1<<(N-1)){
        vector<lint> p;
        vector<lint> acum;
        rep(j,N){
            acum.push_back(P[j]);
            if(j==N-1 || i&(1<<j)){
                sort(all(acum));
                for(auto e:acum) p.push_back(e);
                acum.clear();
            }
        }
        rep(j,N) for(int k=j+1;k<N;k++) if(p[j]>p[k]) ans++;
    }
    cout << ans.val() << endl;
    /*segtree<mint,op,e> seg(N);
    segtree<mint,op,e> n_inv(N);
    mint minus=0;
    mint fans=0;
    rep(i,N){
        fans+=n_inv.prod(P[i]+1,N);
        n_inv.set(P[i],1);
    }
    fans*=pow_mod(2,N-1,MOD);
    rep(i,N){
        mint sum=seg.prod(P[i]+1,N);
        sum*=pow_mod(2,N-1,MOD);
        sum*=inv_mod(pow_mod(2,i,MOD),MOD);
        minus+=sum;
        seg.set(P[i],pow_mod(2,i,MOD));
    }
    cout << (fans-minus).val() << endl;*/
}
0