結果
問題 | No.2230 Good Omen of White Lotus |
ユーザー | みここ |
提出日時 | 2023-02-24 22:27:53 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
AC
|
実行時間 | 174 ms / 2,000 ms |
コード長 | 3,429 bytes |
コンパイル時間 | 871 ms |
コンパイル使用メモリ | 81,112 KB |
実行使用メモリ | 15,108 KB |
最終ジャッジ日時 | 2023-10-11 06:29:25 |
合計ジャッジ時間 | 6,008 ms |
ジャッジサーバーID (参考情報) |
judge13 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
7,996 KB |
testcase_01 | AC | 4 ms
8,052 KB |
testcase_02 | AC | 4 ms
7,988 KB |
testcase_03 | AC | 5 ms
8,004 KB |
testcase_04 | AC | 4 ms
8,204 KB |
testcase_05 | AC | 4 ms
8,048 KB |
testcase_06 | AC | 4 ms
8,044 KB |
testcase_07 | AC | 4 ms
8,172 KB |
testcase_08 | AC | 5 ms
8,028 KB |
testcase_09 | AC | 4 ms
7,996 KB |
testcase_10 | AC | 4 ms
8,004 KB |
testcase_11 | AC | 4 ms
8,004 KB |
testcase_12 | AC | 4 ms
8,056 KB |
testcase_13 | AC | 4 ms
8,132 KB |
testcase_14 | AC | 58 ms
8,644 KB |
testcase_15 | AC | 4 ms
8,044 KB |
testcase_16 | AC | 89 ms
8,824 KB |
testcase_17 | AC | 89 ms
9,048 KB |
testcase_18 | AC | 89 ms
8,800 KB |
testcase_19 | AC | 89 ms
8,860 KB |
testcase_20 | AC | 10 ms
8,076 KB |
testcase_21 | AC | 5 ms
8,120 KB |
testcase_22 | AC | 11 ms
8,100 KB |
testcase_23 | AC | 13 ms
8,236 KB |
testcase_24 | AC | 7 ms
8,256 KB |
testcase_25 | AC | 7 ms
8,212 KB |
testcase_26 | AC | 7 ms
8,140 KB |
testcase_27 | AC | 112 ms
14,972 KB |
testcase_28 | AC | 139 ms
15,032 KB |
testcase_29 | AC | 99 ms
10,012 KB |
testcase_30 | AC | 124 ms
10,028 KB |
testcase_31 | AC | 136 ms
15,108 KB |
testcase_32 | AC | 132 ms
14,300 KB |
testcase_33 | AC | 171 ms
11,984 KB |
testcase_34 | AC | 170 ms
11,964 KB |
testcase_35 | AC | 172 ms
12,012 KB |
testcase_36 | AC | 174 ms
11,996 KB |
testcase_37 | AC | 174 ms
11,980 KB |
testcase_38 | AC | 172 ms
11,976 KB |
testcase_39 | AC | 172 ms
12,208 KB |
testcase_40 | AC | 53 ms
9,580 KB |
testcase_41 | AC | 45 ms
8,748 KB |
testcase_42 | AC | 111 ms
10,948 KB |
testcase_43 | AC | 11 ms
8,188 KB |
testcase_44 | AC | 146 ms
11,552 KB |
testcase_45 | AC | 48 ms
8,900 KB |
testcase_46 | AC | 90 ms
10,548 KB |
ソースコード
#include <algorithm> #include <iostream> #include <vector> using namespace std; template <int MOD> struct static_modint { using mint = static_modint; public: int val; static_modint() : val(0) {} static_modint(long long v) { if (std::abs(v) >= mod()) { v %= mod(); } if (v < 0) { v += mod(); } val = v; } mint &operator++() { val++; if (val == mod()) { val = 0; } return *this; } mint &operator--() { if (val == 0) { val = mod(); } val--; return *this; } mint &operator+=(const mint &x) { val += x.val; if (val >= mod()) { val -= mod(); } return *this; } mint &operator-=(const mint &x) { val -= x.val; if (val < 0) { val += mod(); } return *this; } mint &operator*=(const mint &x) { val = (int)((long long)val * x.val % mod()); return *this; } mint &operator/=(const mint &x) { *this *= x.inv(); return *this; } mint operator-() { return mint() - *this; } mint pow(long long n) const { mint x = 1, r = *this; while (n) { if (n & 1) { x *= r; } r *= r; n >>= 1; } return x; } mint inv() const { return pow(mod() - 2); } friend mint operator+(const mint &x, const mint &y) { return mint(x) += y; } friend mint operator-(const mint &x, const mint &y) { return mint(x) -= y; } friend mint operator*(const mint &x, const mint &y) { return mint(x) *= y; } friend mint operator/(const mint &x, const mint &y) { return mint(x) /= y; } friend bool operator==(const mint &x, const mint &y) { return x.val == y.val; } friend bool operator!=(const mint &x, const mint &y) { return x.val != y.val; } friend std::ostream &operator<<(std::ostream &os, const mint &x) { return os << x.val; } friend std::istream &operator>>(std::istream &is, mint &x) { long long v; is >> v; x = mint(v); return is; } private: static constexpr int mod() { return MOD; } }; using mint = static_modint<998244353>; vector<int> v[200005]; int main() { int h, w, n; mint p; cin >> h >> w >> n >> p; for(int i = 0; i < n; i++) { int x, y; cin >> x >> y; x--; y--; v[x].push_back(y); } vector<int> d; for(int x = 0; x < h; x++) { sort(v[x].begin(), v[x].end()); for(int y : v[x]) { int k = upper_bound(d.begin(), d.end(), y) - d.begin(); if(k == d.size()) { d.push_back(y); } else { d[k] = y; } } } int x = d.size(); mint s = 1; for(int i = 0; i < x; i++) { s *= p - 2; } for(int i = x ; i < h + w - 3; i++) { s *= p - 1; } s /= p.pow(h + w - 3); cout << 1 - s << endl; }