結果

問題 No.2615 ペアの作り方
ユーザー inkyaman
提出日時 2024-03-24 11:22:30
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 104 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 954 ms
コンパイル使用メモリ 120,264 KB
最終ジャッジ日時 2025-02-20 13:36:06
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <math.h>
#include <cmath>
#include <stack>
#include <map>
#include <set>
#include <numeric>
#include <iomanip>
#include <climits>
#include <functional>
#include <cassert>
#include <tuple>
using namespace std;
using ll = long long;

int N;
ll mod = 998244353;

int main() {

    cin >> N;
    vector<pair<int,int>> vec;
    for(int i = 0; i < N; ++i) {
        int x; cin >> x;
        vec.push_back({x,0});
    }

    for(int i = 0; i < N; ++i) {
        int y; cin >> y;
        vec.push_back({y,1});
    }

    sort(vec.begin(), vec.end());

    int xres = N, yres = N;
    for(int i = 0; i < N; ++i) {
        auto [v,t] = vec[i];
        if(t == 0) xres--;
        if(t == 1) yres--;
    }

    ll ans = 1;
    for(int i = 1; i <= xres; ++i) {
        ans *= i;
        ans %= mod;
    }

    for(int i = 1; i <= yres; ++i) {
        ans *= i;
        ans %= mod;
    }

    cout << ans << endl;

}
0