結果

問題 No.2230 Good Omen of White Lotus
ユーザー hiro71687khiro71687k
提出日時 2023-02-24 23:21:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 181 ms / 2,000 ms
コード長 1,063 bytes
コンパイル時間 4,398 ms
コンパイル使用メモリ 265,708 KB
実行使用メモリ 15,152 KB
最終ジャッジ日時 2023-10-11 06:57:13
合計ジャッジ時間 9,725 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,352 KB
testcase_01 AC 1 ms
4,352 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 2 ms
4,352 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 2 ms
4,356 KB
testcase_06 AC 1 ms
4,352 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,356 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 1 ms
4,348 KB
testcase_12 AC 2 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 63 ms
7,296 KB
testcase_15 AC 1 ms
4,352 KB
testcase_16 AC 97 ms
9,412 KB
testcase_17 AC 97 ms
9,488 KB
testcase_18 AC 96 ms
9,336 KB
testcase_19 AC 97 ms
9,352 KB
testcase_20 AC 7 ms
4,356 KB
testcase_21 AC 2 ms
4,352 KB
testcase_22 AC 9 ms
4,352 KB
testcase_23 AC 10 ms
4,348 KB
testcase_24 AC 14 ms
8,788 KB
testcase_25 AC 13 ms
8,740 KB
testcase_26 AC 13 ms
8,760 KB
testcase_27 AC 116 ms
15,008 KB
testcase_28 AC 145 ms
15,012 KB
testcase_29 AC 129 ms
15,016 KB
testcase_30 AC 158 ms
14,880 KB
testcase_31 AC 152 ms
15,056 KB
testcase_32 AC 152 ms
15,152 KB
testcase_33 AC 174 ms
15,016 KB
testcase_34 AC 175 ms
14,812 KB
testcase_35 AC 174 ms
15,112 KB
testcase_36 AC 174 ms
15,016 KB
testcase_37 AC 175 ms
15,108 KB
testcase_38 AC 177 ms
14,860 KB
testcase_39 AC 181 ms
15,016 KB
testcase_40 AC 60 ms
10,472 KB
testcase_41 AC 51 ms
7,532 KB
testcase_42 AC 109 ms
8,744 KB
testcase_43 AC 15 ms
8,812 KB
testcase_44 AC 146 ms
11,524 KB
testcase_45 AC 57 ms
8,348 KB
testcase_46 AC 95 ms
11,692 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace atcoder;
using namespace std;
using ll=long long;
using ld=double;
ld pie=3.14159265359;
ll mod=998244353;
ll inf=100000;
ll op(ll a,ll b){
    return max(a,b);
}
ll e(){
    return -1;
}
int main(){
    ll h,w,n,p;
    cin >> h >> w >> n >> p;
    vector<ll>x(n),y(n);
    vector<pair<ll,ll>>pp(n);
    for (ll i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        pp[i]={x[i],y[i]};
    }
    sort(pp.begin(),pp.end());
    vector<ll>a(w+1,0);
    segtree<ll,op,e>seg(a);
    for (ll i = 0; i < n; i++)
    {
        ll x=seg.prod(0,pp[i].second+1);
        seg.set(pp[i].second,x+1);
    }
    ll dai=seg.all_prod();
    ll hiku=1;
    ll bo=1;
    for (ll i = 0; i <h-1+w-2-dai; i++)
    {
        hiku*=p-1;
        hiku%=mod;
        bo*=p;
        bo%=mod;
    }
    for (ll i = 0; i < dai; i++)
    {
        hiku*=p-2;
        hiku%=mod;
        bo*=p;
        bo%=mod;
    }
    hiku=mod+bo-hiku;
    hiku%=mod;
    hiku*=inv_mod(bo,mod);
    hiku%=mod;
    cout << hiku << endl;
}
0