結果
問題 | No.2230 Good Omen of White Lotus |
ユーザー |
![]() |
提出日時 | 2023-02-24 23:02:24 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 66 ms / 2,000 ms |
コード長 | 2,663 bytes |
コンパイル時間 | 1,025 ms |
コンパイル使用メモリ | 125,540 KB |
最終ジャッジ日時 | 2025-02-10 22:12:42 |
ジャッジサーバーID (参考情報) |
judge3 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 44 |
ソースコード
#include <iostream>#include <algorithm>#include <iomanip>#include <vector>#include <queue>#include <deque>#include <set>#include <map>#include <tuple>#include <cmath>#include <numeric>#include <functional>#include <cassert>#include <atcoder/modint>#define debug_value(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << #x << "=" << x << endl;#define debug(x) cerr << "line" << __LINE__ << ":<" << __func__ << ">:" << x << endl;template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }using namespace std;typedef long long ll;template<typename T>vector<vector<T>> vec2d(int n, int m, T v){return vector<vector<T>>(n, vector<T>(m, v));}template<typename T>vector<vector<vector<T>>> vec3d(int n, int m, int k, T v){return vector<vector<vector<T>>>(n, vector<vector<T>>(m, vector<T>(k, v)));}template<typename T>void print_vector(vector<T> v, char delimiter=' '){if(v.empty()) {cout << endl;return;}for(int i = 0; i+1 < v.size(); i++) cout << v[i] << delimiter;cout << v.back() << endl;}using mint = atcoder::modint998244353;ostream& operator<<(ostream& os, const mint& m){os << m.val();return os;}using P = pair<int, int>;/*** verified(strict=true): https://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=6665054*/template<typename T>int longest_increasing_sequence(const vector<T> &v, bool strict){if(v.empty()) return 0;int n = v.size();const T inf = (*max_element(v.begin(), v.end()))+1;vector<T> dp(n, inf);for(int i = 0; i < n; i++){if(strict){auto p = lower_bound(dp.begin(), dp.end(), v[i]);int j = p-dp.begin();dp[j] = v[i];}else{auto p = upper_bound(dp.begin(), dp.end(), v[i]);int j = p-dp.begin();dp[j] = v[i];}}for(int j = n-1; j >= 0; j--){if(dp[j] != inf) return j+1;}assert(false);}int main(){ios::sync_with_stdio(false);cin.tie(0);cout << setprecision(10) << fixed;int h, w, n, p; cin >> h >> w >> n >> p;vector<P> vp;for(int i = 0; i < n; i++){int x, y; cin >> x >> y;vp.push_back(P(x, y));}sort(vp.begin(), vp.end());vector<int> v;for(int i = 0; i < n; i++) v.push_back(vp[i].second);int lis = longest_increasing_sequence(v, false);mint q = 1-mint(p).inv();mint q2 = 1-2*mint(p).inv();mint ans = 1-q2.pow(lis)*q.pow(h+w-3-lis);cout << ans << endl;}