結果

問題 No.2197 Same Dish
ユーザー FplusFplusFFplusFplusF
提出日時 2023-01-20 22:14:51
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,082 bytes
コンパイル時間 2,392 ms
コンパイル使用メモリ 208,476 KB
実行使用メモリ 5,484 KB
最終ジャッジ日時 2023-09-05 14:32:44
合計ジャッジ時間 4,270 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,380 KB
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 67 ms
5,484 KB
testcase_22 AC 66 ms
4,488 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
using ll=long long;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll,ll>;
const ll INF=(1ll<<60);
template<class T> void chmin(T &a,T b){
    if(a>b){
        a=b;
    }
}
template<class T> void chmax(T &a,T b){
    if(a<b){
        a=b;
    }
}
ll modpow(ll a,ll b,ll mod){
    if(b==0) return 1;
    ll p=a,ret=1;
    for(ll i=0;i<=62;i++){
        if(b&(1ll<<i)){
            ret*=p;
            ret%=mod;
        }
        p=(p%mod)*(p%mod);
        p%=mod;
    }
    return ret;
}
int main(){
    const ll mod=998244353;
    ll n,k;
    cin >> n >> k;
    vector<pll> p(n);
    rep(i,n) cin >> p[i].second >> p[i].first;
    sort(all(p));
    ll r=1,x=k;
    priority_queue<ll,vector<ll>,greater<ll>> pq;
    for(auto &[a,b]:p){
        swap(a,b);
        while(!pq.empty()&&pq.top()<=a){
            pq.pop();
            x++;
        }
        r*=x;
        r%=mod;
        x--;
        pq.push(b);
    }
    cout << (modpow(k,n,mod)-r+mod)%mod << endl;
}
0