結果

問題 No.2615 ペアの作り方
ユーザー inkyamaninkyaman
提出日時 2024-03-24 11:22:30
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 105 ms / 2,000 ms
コード長 1,031 bytes
コンパイル時間 1,535 ms
コンパイル使用メモリ 123,932 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-03-24 11:22:34
合計ジャッジ時間 3,722 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
6,676 KB
testcase_01 AC 2 ms
6,676 KB
testcase_02 AC 2 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 3 ms
6,676 KB
testcase_10 AC 3 ms
6,676 KB
testcase_11 AC 3 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 3 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 105 ms
6,676 KB
testcase_16 AC 105 ms
6,676 KB
testcase_17 AC 103 ms
6,676 KB
testcase_18 AC 104 ms
6,676 KB
testcase_19 AC 104 ms
6,676 KB
testcase_20 AC 104 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

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