結果

問題 No.1864 Shortest Paths Counting
ユーザー otoshigootoshigo
提出日時 2022-03-05 06:20:15
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 85 ms / 2,000 ms
コード長 1,769 bytes
コンパイル時間 5,550 ms
コンパイル使用メモリ 269,432 KB
実行使用メモリ 10,824 KB
最終ジャッジ日時 2023-09-26 11:12:36
合計ジャッジ時間 8,688 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,384 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,384 KB
testcase_05 AC 1 ms
4,380 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 2 ms
4,380 KB
testcase_09 AC 58 ms
6,608 KB
testcase_10 AC 60 ms
6,812 KB
testcase_11 AC 58 ms
6,508 KB
testcase_12 AC 73 ms
8,208 KB
testcase_13 AC 58 ms
6,420 KB
testcase_14 AC 62 ms
6,972 KB
testcase_15 AC 65 ms
7,272 KB
testcase_16 AC 58 ms
6,508 KB
testcase_17 AC 64 ms
7,332 KB
testcase_18 AC 63 ms
7,168 KB
testcase_19 AC 59 ms
6,620 KB
testcase_20 AC 67 ms
7,548 KB
testcase_21 AC 58 ms
6,148 KB
testcase_22 AC 62 ms
6,992 KB
testcase_23 AC 58 ms
6,604 KB
testcase_24 AC 2 ms
4,376 KB
testcase_25 AC 85 ms
10,824 KB
testcase_26 AC 35 ms
6,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using mint = modint998244353;
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,a,b) for (int i = a; i < b; i++)
#define rrep2(i,a,b) for (int i = a-1; i >= b; i--)
#define rep3(i,a,b,c) for (int i = a; i < b; i+=c)
#define rrep3(i,a,b,c) for (int i = a-1; i >= b; i-=c)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
template<class T> bool chmax(T &a, T b){if (a < b){a = b;return true;} else return false;}
template<class T> bool chmin(T &a, T b){if (a > b){a = b;return true;} else return false;}
template<class T> T pow(T x, ll y){if (y == 0) return 1;T p = pow(x,y/2);if (y%2 == 0) return p*p;else return p*p*x;}

mint op(mint a, mint b){return a+b;}
mint e(){return 0;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n; cin >> n;
    vector<ll> X(n), Y(n);
    rep(i,n){
        ll x,y; cin >> x >> y;
        X[i] = x + y;
        Y[i] = x - y;
    }
    rrep(i,n){
        X[i] -= X[0];
        Y[i] -= Y[0];
    }
    rep(i,n){
        if (X[n-1] < 0) X[i] = -X[i];
        if (Y[n-1] < 0) Y[i] = -Y[i];
    }
    vector<pair<ll,ll>> vp, vsp;
    rep(i,n){
        if (X[i] >= 0 && X[i] <= X[n-1] && Y[i] >= 0 && Y[i] <= Y[n-1]) vp.push_back(make_pair(X[i],Y[i]));
    }
    sort(all(vp));
    int l = vp.size();
    rep2(i,1,l-1){
        vsp.push_back(make_pair(-vp[i].second,-i));
    }
    sort(all(vsp));
    segtree<mint,op,e> seg(l);
    mint ans = 1;
    for (auto [c,i]:vsp){
        c = -c;
        i = -i;
        mint m = seg.prod(i+1,l) + 1;
        ans += m;
        seg.set(i,m);
    }
    cout << ans.val() << endl;
}
0