結果
問題 | No.2230 Good Omen of White Lotus |
ユーザー | umimel |
提出日時 | 2023-02-25 01:22:55 |
言語 | C++14 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 105 ms / 2,000 ms |
コード長 | 1,945 bytes |
コンパイル時間 | 1,753 ms |
コンパイル使用メモリ | 178,508 KB |
実行使用メモリ | 10,508 KB |
最終ジャッジ日時 | 2024-09-13 06:39:28 |
合計ジャッジ時間 | 5,201 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
6,816 KB |
testcase_01 | AC | 2 ms
6,944 KB |
testcase_02 | AC | 2 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 2 ms
6,940 KB |
testcase_05 | AC | 2 ms
6,944 KB |
testcase_06 | AC | 2 ms
6,940 KB |
testcase_07 | AC | 2 ms
6,944 KB |
testcase_08 | AC | 2 ms
6,940 KB |
testcase_09 | AC | 2 ms
6,944 KB |
testcase_10 | AC | 2 ms
6,940 KB |
testcase_11 | AC | 2 ms
6,940 KB |
testcase_12 | AC | 2 ms
6,944 KB |
testcase_13 | AC | 2 ms
6,944 KB |
testcase_14 | AC | 31 ms
6,940 KB |
testcase_15 | AC | 2 ms
6,940 KB |
testcase_16 | AC | 44 ms
6,940 KB |
testcase_17 | AC | 44 ms
6,940 KB |
testcase_18 | AC | 45 ms
6,944 KB |
testcase_19 | AC | 43 ms
6,940 KB |
testcase_20 | AC | 5 ms
6,940 KB |
testcase_21 | AC | 2 ms
6,944 KB |
testcase_22 | AC | 5 ms
6,944 KB |
testcase_23 | AC | 6 ms
6,940 KB |
testcase_24 | AC | 4 ms
7,172 KB |
testcase_25 | AC | 4 ms
7,296 KB |
testcase_26 | AC | 4 ms
7,376 KB |
testcase_27 | AC | 60 ms
10,504 KB |
testcase_28 | AC | 59 ms
10,444 KB |
testcase_29 | AC | 63 ms
10,468 KB |
testcase_30 | AC | 70 ms
10,456 KB |
testcase_31 | AC | 70 ms
10,428 KB |
testcase_32 | AC | 69 ms
10,508 KB |
testcase_33 | AC | 102 ms
10,360 KB |
testcase_34 | AC | 105 ms
10,404 KB |
testcase_35 | AC | 104 ms
10,480 KB |
testcase_36 | AC | 104 ms
10,332 KB |
testcase_37 | AC | 102 ms
10,440 KB |
testcase_38 | AC | 104 ms
10,408 KB |
testcase_39 | AC | 104 ms
10,424 KB |
testcase_40 | AC | 34 ms
8,312 KB |
testcase_41 | AC | 32 ms
6,944 KB |
testcase_42 | AC | 63 ms
6,940 KB |
testcase_43 | AC | 7 ms
7,456 KB |
testcase_44 | AC | 86 ms
7,896 KB |
testcase_45 | AC | 34 ms
6,940 KB |
testcase_46 | AC | 55 ms
8,980 KB |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using pll = pair<ll, ll>; #define drep(i, cc, n) for (ll i = (cc); i <= (n); ++i) #define rep(i, n) drep(i, 0, n - 1) #define all(a) (a).begin(), (a).end() #define pb push_back #define fi first #define se second const ll MOD = 1000000007; const ll MOD2 = 998244353; const ll INF = 1LL << 60; const ll MAX_N = 2e5; ll pow_mod(ll x, ll n, ll mod){ ll ret = 1; while(n > 0){ if(n & 1) ret = (ret*x)%mod; x = x*x%mod; n >>=1; } return ret; } struct SegmentTree{ ll n; vector<ll> dat; SegmentTree(ll n_){ n = 1; while(n < n_) n*=2; dat.resize(2*n, 0); } void update(ll k, ll a){ k += n-1; dat[k] = a; while(k > 0){ k = (k-1)/2; dat[k] = max(dat[2*k+1], dat[2*k+2]); } } // the minimun element of [a, b) ll query(ll a, ll b){return query_sub(a, b, 0, 0, n);} ll query_sub(ll a, ll b, ll k, ll l, ll r){ if(r <= a || b <= l){ return 0; }else if(a <= l && r <= b){ return dat[k]; }else{ ll vl = query_sub(a, b, 2*k+1, l, (l+r)/2); ll vr = query_sub(a, b, 2*k+2, (l+r)/2, r); return max(vl, vr); } } }; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); ll mod = MOD2; ll h, w, n, p; cin >> h >> w >> n >> p; vector<pll> P(n); rep(i, n){ cin >> P[i].fi >> P[i].se; P[i].fi--; P[i].se--; } sort(all(P)); SegmentTree ST(w); rep(i, n) ST.update(P[i].se, ST.query(0, P[i].se+1)+1); ll good = ST.query(0, w); ll bad = (h+w-3) - good; ll ans = 1; ll inv_p = pow_mod(p, mod-2, mod); ans = (ans * pow_mod(((p-2)*inv_p)%mod, good, mod))%mod; ans = (ans * pow_mod(((p-1)*inv_p)%mod, bad, mod))%mod; cout << (1 - ans + mod)%mod << endl; }