結果
問題 | No.2230 Good Omen of White Lotus |
ユーザー | chro_96 |
提出日時 | 2023-02-24 23:17:22 |
言語 | C (gcc 12.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,315 bytes |
コンパイル時間 | 346 ms |
コンパイル使用メモリ | 32,000 KB |
実行使用メモリ | 7,356 KB |
最終ジャッジ日時 | 2024-09-13 06:05:40 |
合計ジャッジ時間 | 4,588 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | AC | 3 ms
6,944 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | AC | 3 ms
6,940 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | WA | - |
testcase_41 | WA | - |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | WA | - |
testcase_45 | WA | - |
testcase_46 | WA | - |
ソースコード
#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]+a_[1] < b_[0]+b_[1]) { return -1; } if (a_[0]+a_[1] > b_[0]+b_[1]) { return 1; } if (a_[0] > b_[0]) { return -1; } if (a_[0] < b_[0]) { 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 <= h) { size <<= 1; } for (int i = 0; i < n; i++) { int tmp = max_segt(t, 0, xy[i][0], size); set_segt(t, xy[i][0], tmp+1, size); } max = max_segt(t, 0, h+1, size); ans = power_mod(p-2LL, (long long)max, mod_num); ans *= power_mod(p-1LL, (long long)(h+w-1-max), mod_num); ans %= mod_num; ans *= power_mod(p, ((long long)(h+w-1))*(mod_num-2LL), mod_num); ans %= mod_num; ans = 1LL+mod_num-ans; ans %= mod_num; printf("%lld\n", ans); return 0; }