結果

問題 No.2197 Same Dish
ユーザー たたき@競プロたたき@競プロ
提出日時 2023-07-12 20:19:49
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 904 bytes
コンパイル時間 5,195 ms
コンパイル使用メモリ 310,676 KB
実行使用メモリ 5,456 KB
最終ジャッジ日時 2023-10-12 10:35:10
合計ジャッジ時間 7,201 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,356 KB
testcase_02 AC 1 ms
4,348 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 1 ms
4,352 KB
testcase_05 AC 1 ms
4,356 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 WA -
testcase_09 AC 2 ms
4,356 KB
testcase_10 WA -
testcase_11 AC 1 ms
4,348 KB
testcase_12 WA -
testcase_13 AC 12 ms
4,352 KB
testcase_14 AC 70 ms
5,432 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 AC 80 ms
5,108 KB
testcase_20 WA -
testcase_21 AC 78 ms
5,104 KB
testcase_22 AC 77 ms
5,100 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353; //1000000007;
using ll=long long;
using pp=pair<int,int>;
#define sr string 
#define vc vector
#define db double
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define pque priority_queue
#define bpc(a) __builtin_popcount(a)
ll mpow(ll a,ll t,ll m){
	if(t==0)return 1%m;
	ll res=mpow(a,t/2,m);
	res=res*res%m;
	if(t&1)res*=a;
	return res%m;
}
int main(){
    ll n,k;cin>>n>>k;
    vc<pp>v;
    rep(i,n){
    	int l,r;cin>>l>>r;
    	v.pb({l,1});
    	v.pb({r,-1});
    }
    sort(all(v));
    ll m=998244353;
    ll ans=1;
    int now=0;
    for(auto [z,t]:v){
    	if(t==1){
    		ans*=k-now;
    		ans%=m;
    		now++;
    	}
    	else now--;
    }
    ans=mpow(k,n,m)-ans;
    cout<<ans;
}
    	
0