結果

問題 No.2615 ペアの作り方
ユーザー 👑 tipstar0125tipstar0125
提出日時 2024-01-26 21:49:37
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 42 ms / 2,000 ms
コード長 5,217 bytes
コンパイル時間 1,837 ms
コンパイル使用メモリ 173,016 KB
実行使用メモリ 6,676 KB
最終ジャッジ日時 2024-01-26 21:49:40
合計ジャッジ時間 2,884 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 1 ms
6,676 KB
testcase_09 AC 2 ms
6,676 KB
testcase_10 AC 2 ms
6,676 KB
testcase_11 AC 2 ms
6,676 KB
testcase_12 AC 2 ms
6,676 KB
testcase_13 AC 2 ms
6,676 KB
testcase_14 AC 2 ms
6,676 KB
testcase_15 AC 42 ms
6,676 KB
testcase_16 AC 42 ms
6,676 KB
testcase_17 AC 42 ms
6,676 KB
testcase_18 AC 42 ms
6,676 KB
testcase_19 AC 41 ms
6,676 KB
testcase_20 AC 41 ms
6,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using namespace std;
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
typedef string str;

template <typename T> using v = vector<T>;
template <typename T> using vv = vector<vector<T>>;
template <typename T> using vvv = vector<vector<vector<T>>>;
template <typename T> inline void errv(T &v) {
    for(auto x : v)
        cerr << x << " ";
    cerr << endl;
}
inline void errv(vector<bool> &v) {
    for(auto x : v)
        cerr << (x ? 1 : 0) << " ";
    cerr << endl;
}
template <typename T> inline void dbgn(T x) {
    cerr << x << endl;
}
template <typename T> inline void dbgn(vector<T> &v) {
    errv(v);
}
template <typename T> inline void dbgn(vector<vector<T>> &m) {
    for(auto &v : m)
        errv(v);
}
template <typename T> inline bool chmax(T &a, T b) {
    return ((a < b) ? (a = b, true) : (false));
}
template <typename T> inline bool chmin(T &a, T b) {
    return ((a > b) ? (a = b, true) : (false));
}
template <typename T> inline T sum(vector<T> &a) {
    T ret{};
    for(auto &i : a)
        ret += i;
    return ret;
}
template <typename T> inline T min(vector<T> &a) {
    T ret = a[0];
    for(auto &i : a)
        chmin(ret, i);
    return ret;
}
template <typename T> inline T max(vector<T> &a) {
    T ret = a[0];
    for(auto &i : a)
        chmax(ret, i);
    return ret;
}
template <long long mod> struct modint {
    modint(ll v = 0) : value(normalize(v)) {
    }
    ll val() const {
        return value;
    }
    void normalize() {
        value = normalize(value);
    }
    ll normalize(ll v) {
        if(v <= mod && v >= -mod) {
            if(v < 0)
                v += mod;
            return v;
        }
        if(v > 0 && v < 2 * mod) {
            v -= mod;
            return v;
        }
        if(v < 0 && v > -2 * mod) {
            v += 2 * mod;
            return v;
        }
        v %= mod;
        if(v < 0)
            v += mod;
        return v;
    }
    modint<mod> &operator=(ll v) {
        value = normalize(v);
        return *this;
    }
    bool operator==(const modint &o) const {
        return value == o.val();
    }
    bool operator!=(const modint &o) const {
        return value != o.val();
    }
    const modint &operator+() const {
        return *this;
    }
    const modint &operator-() const {
        return value ? mod - value : 0;
    }
    const modint operator+(const modint &o) const {
        return value + o.val();
    }
    modint &operator+=(const modint &o) {
        value += o.val();
        if(value >= mod)
            value -= mod;
        return *this;
    }
    const modint operator-(const modint &o) const {
        return value - o.val();
    }
    modint &operator-=(const modint &o) {
        value -= o.val();
        if(value < 0)
            value += mod;
        return *this;
    }
    const modint operator*(const modint &o) const {
        return (value * o.val()) % mod;
    }
    modint &operator*=(const modint &o) {
        value *= o.val();
        value %= mod;
        return *this;
    }
    const modint operator/(const modint &o) const {
        return operator*(o.inv());
    }
    modint &operator/=(const modint &o) {
        return operator*=(o.inv());
    }
    const modint pow(ll n) const {
        modint ans = 1, x(value);
        while(n > 0) {
            if(n & 1)
                ans *= x;
            x *= x;
            n >>= 1;
        }
        return ans;
    }
    const modint inv() const {
        ll a = value, b = mod, u = 1, v = 0;
        while(b) {
            ll t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return u;
    }
    friend ostream &operator<<(ostream &os, const modint &x) {
        return os << x.val();
    }
    template <typename T> friend modint operator+(T t, const modint &o) {
        return o + t;
    }
    template <typename T> friend modint operator-(T t, const modint &o) {
        return -o + t;
    }
    template <typename T> friend modint operator*(T t, const modint &o) {
        return o * t;
    }
    template <typename T> friend modint operator/(T t, const modint &o) {
        return o.inv() * t;
    }

  private:
    ll value;
};

#define d(x) dbgn(x);
#define rep(i, c, n) for(int i = c; i < n; ++i)
#define repa(i, a) for(auto i : a)
#define so(v) sort(v.begin(), v.end())
#define rso(v) sort(v.rbegin(), v.rend())

using P = pair<ll, int>;
using Dijkstra = priority_queue<P, vector<P>, greater<P>>;
// using mint = modint<1000000007>;
using mint = modint<998244353>;

const ll INF = 1LL << 60;
const ll MOD = 998244353;
// const ll MOD = 1000000007;
int dx[8] = {0, 1, 0, -1, -1, -1, 1, 1};
int dy[8] = {1, 0, -1, 0, -1, 1, -1, 1};

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    v<int> X(N);
    v<int> Y(N);
    rep(i, 0, N) cin >> X[i];
    rep(i, 0, N) cin >> Y[i];
    so(X);
    so(Y);
    int i = 0;
    int x = 0;
    int y = 0;
    mint ans = 1;
    while(i < N) {
        if(X[x] > Y[y]) {
            y += 1;
            ans *= y;
        } else {
            x += 1;
            ans *= x;
        }
        i += 1;
    }
    cout << ans.val() << endl;
}
0