結果

問題 No.2615 ペアの作り方
ユーザー startcppstartcpp
提出日時 2022-02-05 19:14:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 102 ms / 2,000 ms
コード長 685 bytes
コンパイル時間 877 ms
コンパイル使用メモリ 73,484 KB
実行使用メモリ 7,396 KB
最終ジャッジ日時 2024-01-26 20:50:05
合計ジャッジ時間 3,630 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
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 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 3 ms
6,676 KB
testcase_14 AC 3 ms
6,676 KB
testcase_15 AC 101 ms
7,396 KB
testcase_16 AC 101 ms
7,396 KB
testcase_17 AC 100 ms
7,396 KB
testcase_18 AC 100 ms
7,396 KB
testcase_19 AC 98 ms
7,396 KB
testcase_20 AC 102 ms
7,396 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

const int mod = 998244353;
int n;
P pa[200000];
int fact[100001];

signed main() {
	int i;
	
	cin >> n;
	
	fact[0] = 1;
	for (i = 1; i <= n; i++) {
		fact[i] = fact[i - 1] * i % mod;
	}
	
	for (i = 0; i < n; i++) {
		int x;
		cin >> x;
		pa[i] = P(x, 'x');
	}
	
	for (i = 0; i < n; i++) {
		int y;
		cin >> y;
		pa[n + i] = P(y, 'y');
	}
	
	sort(pa, pa + 2 * n);
	
	int cntx = 0;
	int cnty = 0;
	for (i = 0; i < n; i++) {
		if (pa[i].second == 'x') {
			cntx++;
		}
		else {
			cnty++;
		}
	}
	
	cout << fact[cntx] * fact[cnty] % mod << endl;
	return 0;
}
0