結果

問題 No.2197 Same Dish
ユーザー Manuel1024
提出日時 2023-01-20 21:47:32
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 64 ms / 2,000 ms
コード長 1,090 bytes
コンパイル時間 915 ms
コンパイル使用メモリ 94,372 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-06-23 09:44:07
合計ジャッジ時間 2,515 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20
権限があれば一括ダウンロードができます

ソースコード

diff #
プレゼンテーションモードにする

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <deque>
#include <cmath>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 998244353;
ll modpow(ll a, ll x){
ll res = 1;
for(; x > 0; x >>= 1){
if(x & 1){
res *= a;
res %= MOD;
}
a *= a;
a %= MOD;
}
return res;
}
int main(){
int n, k; cin >> n >> k;
vector<int> l(n), r(n);
for(int i = 0; i < n; i++) cin >> l[i] >> r[i];
const int lim = 200010;
vector<int> in(lim, 0), out(lim, 0);
for(int i = 0; i < n; i++){
in[l[i]]++;
out[r[i]]++;
}
bool overlap = false;
ll ans = 1;
int cnt = 0;
for(int i = 0; i < lim; i++){
cnt -= out[i];
for(int j = 0; j < in[i]; j++){
if(cnt > 0) overlap = true;
ans *= k-cnt;
ans %= MOD;
cnt++;
}
}
cout << (modpow(k, n)-ans+MOD)%MOD << endl;
return 0;
}
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
0