結果
問題 | No.2230 Good Omen of White Lotus |
ユーザー | 👑 chro_96 |
提出日時 | 2023-02-24 23:27:12 |
言語 | C (gcc 12.3.0) |
結果 |
AC
|
実行時間 | 147 ms / 2,000 ms |
コード長 | 2,293 bytes |
コンパイル時間 | 766 ms |
コンパイル使用メモリ | 30,476 KB |
実行使用メモリ | 7,216 KB |
最終ジャッジ日時 | 2023-10-11 06:58:53 |
合計ジャッジ時間 | 5,191 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 2 ms
5,720 KB |
testcase_01 | AC | 3 ms
5,836 KB |
testcase_02 | AC | 3 ms
5,724 KB |
testcase_03 | AC | 2 ms
5,816 KB |
testcase_04 | AC | 2 ms
5,840 KB |
testcase_05 | AC | 2 ms
5,600 KB |
testcase_06 | AC | 2 ms
5,596 KB |
testcase_07 | AC | 4 ms
5,732 KB |
testcase_08 | AC | 3 ms
5,728 KB |
testcase_09 | AC | 2 ms
5,652 KB |
testcase_10 | AC | 2 ms
5,828 KB |
testcase_11 | AC | 2 ms
5,668 KB |
testcase_12 | AC | 3 ms
5,700 KB |
testcase_13 | AC | 2 ms
5,652 KB |
testcase_14 | AC | 44 ms
6,032 KB |
testcase_15 | AC | 4 ms
5,824 KB |
testcase_16 | AC | 66 ms
6,212 KB |
testcase_17 | AC | 66 ms
6,120 KB |
testcase_18 | AC | 67 ms
6,320 KB |
testcase_19 | AC | 67 ms
6,396 KB |
testcase_20 | AC | 6 ms
5,860 KB |
testcase_21 | AC | 3 ms
5,700 KB |
testcase_22 | AC | 8 ms
5,792 KB |
testcase_23 | AC | 8 ms
5,796 KB |
testcase_24 | AC | 2 ms
5,724 KB |
testcase_25 | AC | 3 ms
5,720 KB |
testcase_26 | AC | 2 ms
5,828 KB |
testcase_27 | AC | 86 ms
6,260 KB |
testcase_28 | AC | 94 ms
6,248 KB |
testcase_29 | AC | 90 ms
6,256 KB |
testcase_30 | AC | 97 ms
6,304 KB |
testcase_31 | AC | 98 ms
6,028 KB |
testcase_32 | AC | 98 ms
7,156 KB |
testcase_33 | AC | 144 ms
7,020 KB |
testcase_34 | AC | 144 ms
7,216 KB |
testcase_35 | AC | 146 ms
6,916 KB |
testcase_36 | AC | 145 ms
7,024 KB |
testcase_37 | AC | 146 ms
7,016 KB |
testcase_38 | AC | 147 ms
7,196 KB |
testcase_39 | AC | 146 ms
7,092 KB |
testcase_40 | AC | 45 ms
6,136 KB |
testcase_41 | AC | 42 ms
6,028 KB |
testcase_42 | AC | 88 ms
6,504 KB |
testcase_43 | AC | 8 ms
5,648 KB |
testcase_44 | AC | 119 ms
6,888 KB |
testcase_45 | AC | 45 ms
6,092 KB |
testcase_46 | AC | 77 ms
6,392 KB |
ソースコード
#include <stdio.h> #include <stdlib.h> int cmp (const void *a, const void *b) { int *a_ = (int *)a; int *b_ = (int *)b; if (a_[0] > b_[0]) { return 1; } if (a_[0] < b_[0]) { return -1; } if (a_[1] > b_[1]) { return 1; } if (a_[1] < b_[1]) { return -1; } return 0; } long long power_mod (long long a, long long b, long long mod_num) { long long ans = 1LL; if (b > 0LL) { ans = power_mod(a, b/2LL, mod_num); ans = (ans * ans) % mod_num; if (b%2LL == 1LL) { ans = (ans * (a % mod_num)) % mod_num; } } return ans; } void set_segt (int *t, int idx, int val, int size) { idx = idx+size-1; t[idx] = val; while (idx > 0) { idx = (idx-1)/2; t[idx] = t[2*idx+1]; if (t[2*idx+2] > t[idx]) { t[idx] = t[2*idx+2]; } } return; } int max_segt_rec (int *t, int a, int b, int k, int l, int r) { int ans = 0; int tmp = 0; if (r <= a || b <= l) { return 0; } if (a <= l && r <= b) { return t[k]; } ans = max_segt_rec(t, a, b, 2*k+1, l, (l+r)/2); tmp = max_segt_rec(t, a, b, 2*k+2, (l+r)/2, r); if (tmp > ans) { ans = tmp; } return ans; } int max_segt (int *t, int a, int b, int size) { return max_segt_rec(t, a, b, 0, 0, size); } int main () { int h = 0; int w = 0; int n = 0; long long p = 0LL; int xy[200000][2] = {}; int res = 0; long long ans = 0LL; long long mod_num = 998244353LL; int max = 0; int t[600000] = {}; int size = 1; res = scanf("%d", &h); res = scanf("%d", &w); res = scanf("%d", &n); res = scanf("%lld", &p); for (int i = 0; i < n; i++) { res = scanf("%d", xy[i]); res = scanf("%d", xy[i]+1); } qsort(xy, n, sizeof(int)*2, cmp); while (size <= w) { size <<= 1; } for (int i = 0; i < n; i++) { int tmp = max_segt(t, 0, xy[i][1]+1, size); set_segt(t, xy[i][1], tmp+1, size); } max = max_segt(t, 0, w+1, size); ans = power_mod(p-2LL, (long long)max, mod_num); ans *= power_mod(p-1LL, (long long)(h+w-3-max), mod_num); ans %= mod_num; ans *= power_mod(p, ((long long)(h+w-3))*(mod_num-2LL), mod_num); ans %= mod_num; ans = 1LL+mod_num-ans; ans %= mod_num; printf("%lld\n", ans); return 0; }