結果
| 問題 | 
                            No.1864 Shortest Paths Counting
                             | 
                    
| コンテスト | |
| ユーザー | 
                             | 
                    
| 提出日時 | 2022-03-02 20:57:16 | 
| 言語 | C++17  (gcc 13.3.0 + boost 1.87.0)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 1,281 bytes | 
| コンパイル時間 | 4,233 ms | 
| コンパイル使用メモリ | 264,848 KB | 
| 最終ジャッジ日時 | 2025-01-28 04:20:16 | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge2 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 WA * 1 RE * 1 | 
| other | AC * 1 WA * 2 RE * 20 | 
ソースコード
#include <bits/stdc++.h>
using namespace std;
#include <atcoder/all>
using ll = long long;
constexpr ll mod = 998244353;
// 座標圧縮
map<ll, int> compress(const vector<ll>& a) {
  map<ll, int> mem;
  for (auto i: a) mem[i] = 0;
  int cnt = 0;
  for (auto& [i, j]: mem) j = cnt++;
  return mem;
}
int main() {
  // 入力
  int N;
  cin >> N;
  vector<ll> X(N), Y(N);
  for (int i = 0; i < N; ++i) {
    ll a, b;
    cin >> a >> b;
    X[i] = a + b;
    Y[i] = a - b;
  }
  // 座標を反転しておく
  if (X.front() > X.back()) {
    for (auto& i: X) i = -i;
  }
  if (Y.front() > Y.back()) {
    for (auto& i: Y) i = -i;
  }
  // y座標を圧縮
  auto mem = compress(Y);
  for (auto& i: Y) i = mem[i];
  // x, y座標が範囲内の点のみソート
  vector<pair<ll, ll>> points;
  for (int i = 0; i < N; ++i) {
    if (X.front() <= X[i] && X[i] <= X.back() && Y.front() <= Y[i] && Y[i] <= Y.back()) points.push_back({X[i], Y[i]});
  }
  sort(points.begin(), points.end());
  // DP
  atcoder::fenwick_tree<atcoder::modint998244353> ft(mem.size());
  ft.add(points.front().second, 1);
  for (int i = 1; i < N - 1; ++i) {
    ft.add(points[i].second, ft.sum(0, points[i].second + 1));
  }
  // 出力
  cout << ft.sum(0, points.back().second + 1).val() << '\n';
}