結果

問題 No.2230 Good Omen of White Lotus
ユーザー milanis48663220milanis48663220
提出日時 2023-02-24 23:00:48
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
RE  
実行時間 -
コード長 2,635 bytes
コンパイル時間 1,312 ms
コンパイル使用メモリ 127,692 KB
実行使用メモリ 6,572 KB
最終ジャッジ日時 2023-10-11 06:47:21
合計ジャッジ時間 5,308 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,352 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 2 ms
4,352 KB
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 2 ms
4,348 KB
testcase_08 AC 2 ms
4,352 KB
testcase_09 AC 2 ms
4,348 KB
testcase_10 AC 1 ms
4,352 KB
testcase_11 AC 2 ms
4,348 KB
testcase_12 AC 2 ms
4,352 KB
testcase_13 AC 2 ms
4,352 KB
testcase_14 AC 31 ms
5,196 KB
testcase_15 AC 1 ms
4,348 KB
testcase_16 AC 46 ms
6,500 KB
testcase_17 AC 46 ms
6,328 KB
testcase_18 AC 46 ms
6,404 KB
testcase_19 AC 46 ms
6,384 KB
testcase_20 AC 4 ms
4,348 KB
testcase_21 AC 2 ms
4,348 KB
testcase_22 AC 5 ms
4,348 KB
testcase_23 AC 6 ms
4,348 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 AC 2 ms
4,348 KB
testcase_27 AC 51 ms
6,464 KB
testcase_28 AC 55 ms
6,388 KB
testcase_29 AC 51 ms
6,572 KB
testcase_30 AC 58 ms
6,380 KB
testcase_31 AC 56 ms
6,352 KB
testcase_32 AC 45 ms
6,472 KB
testcase_33 AC 73 ms
6,404 KB
testcase_34 AC 74 ms
6,336 KB
testcase_35 AC 74 ms
6,412 KB
testcase_36 AC 74 ms
6,336 KB
testcase_37 AC 74 ms
6,332 KB
testcase_38 AC 73 ms
6,324 KB
testcase_39 AC 74 ms
6,436 KB
testcase_40 AC 22 ms
4,348 KB
testcase_41 AC 22 ms
4,348 KB
testcase_42 AC 49 ms
5,608 KB
testcase_43 AC 3 ms
4,352 KB
testcase_44 AC 63 ms
6,036 KB
testcase_45 AC 24 ms
4,348 KB
testcase_46 AC 38 ms
4,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#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){
    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;
}
0