結果

問題 No.2615 ペアの作り方
ユーザー startcppstartcpp
提出日時 2022-10-02 09:44:57
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 106 ms / 2,000 ms
コード長 733 bytes
コンパイル時間 709 ms
コンパイル使用メモリ 77,396 KB
実行使用メモリ 9,700 KB
最終ジャッジ日時 2024-01-26 20:50:07
合計ジャッジ時間 2,330 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

#include <iostream>
#include <algorithm>
#include <vector>
#define int long long
using namespace std;
typedef pair<int, int> P;

int n;
int x[100000], y[100000];

int fact(int n, int mod) {
	int ret = 1;
	for (int i = 1; i <= n; i++) {
		ret *= i;
		ret %= mod;
	}
	return ret;
}

signed main() {
	int i;
	
	cin >> n;
	for (i = 0; i < n; i++) cin >> x[i];
	for (i = 0; i < n; i++) cin >> y[i];
	
	vector<P> pa;	//(座標, 色)
	for (i = 0; i < n; i++) pa.push_back(P(x[i], 0));
	for (i = 0; i < n; i++) pa.push_back(P(y[i], 1));
	sort(pa.begin(), pa.end());
	
	int black = 0;
	for (i = 0; i < n; i++) if (pa[i].second == 0) black++;
	
	int mod = 998244353;
	cout << fact(black, mod) * fact(n - black, mod) % mod << endl;
	return 0;
}
0