結果

問題 No.2615 ペアの作り方
ユーザー FplusFplusFFplusFplusF
提出日時 2024-01-26 21:28:19
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 961 bytes
コンパイル時間 3,021 ms
コンパイル使用メモリ 256,268 KB
実行使用メモリ 11,136 KB
最終ジャッジ日時 2024-01-26 21:28:24
合計ジャッジ時間 4,707 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 1 ms
6,676 KB
testcase_03 AC 2 ms
6,676 KB
testcase_04 AC 2 ms
6,676 KB
testcase_05 AC 2 ms
6,676 KB
testcase_06 AC 2 ms
6,676 KB
testcase_07 AC 2 ms
6,676 KB
testcase_08 AC 2 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 3 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 99 ms
11,136 KB
testcase_16 AC 100 ms
11,136 KB
testcase_17 AC 81 ms
11,136 KB
testcase_18 AC 106 ms
11,136 KB
testcase_19 AC 99 ms
11,136 KB
testcase_20 AC 99 ms
11,136 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
using ld=long double;
const ll INF=(1ll<<60);
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    const ll mod=998244353;
    ll n;
    cin >> n;
    vector<ll> x(n),y(n),v(2*n);
    rep(i,n) cin >> x[i];
    rep(i,n) cin >> y[i];
    rep(i,n){
        v[i]=x[i];
        v[n+i]=y[i];
    }
    sort(all(v));
    set<ll> st;
    rep(i,n) st.insert(v[i]);
    ll k=n;
    rep(i,n){
        if(st.count(y[i])) k--;
    }
    ll ans=1;
    for(ll i=1;i<=k;i++){
        ans*=i;
        ans%=mod;
    }
    k=n-k;
    for(ll i=1;i<=k;i++){
        ans*=i;
        ans%=mod;
    }
    cout << ans << '\n';
}
0