結果

問題 No.2230 Good Omen of White Lotus
ユーザー hourenhouren
提出日時 2023-02-25 01:04:40
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 1,238 bytes
コンパイル時間 1,637 ms
コンパイル使用メモリ 173,656 KB
実行使用メモリ 9,236 KB
最終ジャッジ日時 2023-10-11 07:27:01
合計ジャッジ時間 5,279 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,352 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,352 KB
testcase_08 AC 2 ms
4,480 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 2 ms
4,348 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 1 ms
4,348 KB
testcase_13 AC 1 ms
4,352 KB
testcase_14 AC 33 ms
5,348 KB
testcase_15 AC 2 ms
4,352 KB
testcase_16 AC 47 ms
6,132 KB
testcase_17 AC 47 ms
6,168 KB
testcase_18 AC 47 ms
6,152 KB
testcase_19 AC 47 ms
6,212 KB
testcase_20 AC 4 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 6 ms
4,348 KB
testcase_24 AC 4 ms
5,904 KB
testcase_25 AC 4 ms
6,132 KB
testcase_26 AC 4 ms
5,868 KB
testcase_27 AC 48 ms
9,148 KB
testcase_28 AC 58 ms
9,008 KB
testcase_29 AC 62 ms
9,236 KB
testcase_30 AC 70 ms
9,000 KB
testcase_31 AC 68 ms
9,088 KB
testcase_32 AC 66 ms
9,076 KB
testcase_33 AC 92 ms
9,172 KB
testcase_34 AC 92 ms
9,012 KB
testcase_35 AC 92 ms
9,176 KB
testcase_36 AC 91 ms
9,124 KB
testcase_37 AC 91 ms
8,956 KB
testcase_38 AC 92 ms
9,124 KB
testcase_39 AC 92 ms
9,140 KB
testcase_40 AC 29 ms
6,724 KB
testcase_41 AC 27 ms
5,324 KB
testcase_42 AC 57 ms
5,868 KB
testcase_43 AC 7 ms
5,960 KB
testcase_44 AC 77 ms
7,292 KB
testcase_45 AC 30 ms
5,328 KB
testcase_46 AC 49 ms
7,200 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
#include <atcoder/segtree>
using namespace atcoder;
using ll = long long;
using P = pair<ll,ll>;
#define fix(x) fixed << setprecision(x)
#define asc(x) x, vector<x>, greater<x>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmin(T&a, const T&b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool chmax(T&a, const T&b){if(a<b){a=b;return 1;}return 0;}
constexpr ll INFLL = (1LL << 62), MOD = 998244353;
constexpr int INF = (1 << 30);
ll mpow(ll x, ll y){
    ll res = 1; x %= MOD;
    while(y){
        if(y%2) res = res * x % MOD;
        x = x * x % MOD;
        y /= 2;
    }
    return res;
}
int op(int a, int b){ return max(a,b); }
int e(){ return 0; }
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll h,w,n,p;
    cin >> h >> w >> n >> p;
    vector<P> x(n);
    rep(i,n) cin >> x[i].first >> x[i].second;
    sort(all(x));
    segtree<int, op, e> seg(w);
    rep(i,n) seg.set(x[i].second-1, seg.prod(0,x[i].second)+1);
    ll a1 = (p-1) * mpow(p, MOD-2) % MOD, a2 = (p-2) * mpow(p, MOD-2) % MOD, k = seg.all_prod();
    cout << (MOD+1-mpow(a2,k)*mpow(a1,h+w-3-k)%MOD) % MOD << '\n';
    return 0;
}
0