結果

問題 No.2615 ペアの作り方
ユーザー vjudge1
提出日時 2025-07-11 23:39:01
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 2,265 bytes
コンパイル時間 3,792 ms
コンパイル使用メモリ 282,104 KB
実行使用メモリ 7,844 KB
最終ジャッジ日時 2025-07-11 23:39:08
合計ジャッジ時間 5,831 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 21
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
const ll INF = LLONG_MAX / 4;
const ll mod1 = 1000000007;
const ll mod9 = 998244353;
const ll Hash = 10000000000000061;
#define all(a) (a).begin(),(a).end()
#define rep(i, n) for (ll i = 0; (i) < (n); ++(i))
#define reps(i, l, r) for(ll i = (l); (i) < (r); ++(i))
ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
ll dy[8] = {0, -1, -1, -1, 0, 1, 1, 1};
template <typename T>
bool chmax(T &a, const T& b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
    if (a > b) { a = b; return true; }
    return false;
}

#define EPS (1e-10)
#define equals(a, b) (fabs((a) - (b)) < EPS)
class Point {
public:
    ld x;
    ld y;
    Point(ld _x = 0, ld _y = 0) : x(_x), y(_y) {}
    Point operator+(Point p) { return Point(x + p.x, y + p.y); }
    Point operator-(Point p) { return Point(x - p.x, y - p.y); }
    Point operator*(ld a) { return Point(a * x, a * y); }
    Point operator/(ld a) { return Point(x / a, y / a); }

    ld abs() { return sqrt(norm()); }
ld norm() { return x * x + y * y; }

    bool operator<(const Point& p) const {
        return !equals(x, p.x) ? x < p.x : y < p.y;
    }
    bool operator==(const Point& p) const {
        return fabs(x - p.x) < (1e-10) && fabs(y - p.y) < (1e-10);
    }
};
typedef Point Vector;
struct Segment {
    Point A;
    Point B;
};
typedef Segment Line;
class Circle {
public:
    Point C;
    ld r;
    Circle(Point C = Point(), ld r = 0.0) : C(C), r(r) {}
};
typedef vector<Point> Polygon;

void solve(){
    ll N; cin >> N;
    vector<ll> x(N), y(N);
    rep(i, N) cin >> x[i];
    rep(i, N) cin >> y[i];
    sort(all(x), greater());
    sort(all(y), greater());
    ll t = 0;
    rep(i, N){
        if(x.back() < y.back()){
            t++; x.pop_back();
        }else{
            y.pop_back();
        }
    }
    ll ans = 1;
    ll MOD = 998244353;
    rep(i, t){
        ans *= (i+1);
        ans %= MOD;
    }
    rep(i, N-t){
        ans *= (i+1);
        ans %= MOD;
    }
    cout << ans << endl;
}

int main(){
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    solve();
}
0