O - Enclosed Points Editorial /

Time Limit: 2 sec / Memory Limit: 1024 MB

配点 : 600

問題文

2 次元平面上の N 個の点からなる集合 S があり、i 番目の点の座標は (x_i, y_i) です。N 個の点の x 座標、y 座標はそれぞれ相異なります。

S の空でない部分集合 T に対して f(T) を、各辺が座標軸と平行であって T の点を全て含むような最小の長方形に含まれる点の個数として定義します。より正確には、

  • f(T) := T に含まれる点について x 座標の最小値と最大値を それぞれ a, b, そして y 座標の最小値と最大値をそれぞれ c, d としたとき、a \leq x_i \leq b かつ c \leq y_i \leq d を満たす 1 \leq i \leq N の個数

S の空でない全ての部分集合 T についての f(T) の和を計算してください。答えは非常に大きくなることがあるので、998244353 で割った余りを出力してください。

制約

  • 1 \leq N \leq 2 \times 10^5
  • -10^9 \leq x_i, y_i \leq 10^9
  • x_i \neq x_j (i \neq j)
  • y_i \neq y_j (i \neq j)
  • 入力は全て整数である

入力

入力は以下の形式で標準入力から与えられる。

N
x_1 y_1
:
x_N y_N

出力

S の空でない全ての部分集合 T についての f(T) の和を 998244353 で割った余りを出力せよ。


入力例 1

3
-1 3
2 1
3 -2

出力例 1

13

1, 2, 3 番目の点をそれぞれ P_1, P_2, P_3 とします。S = \{P_1, P_2, P_3\} の空でない部分集合は 7 個あり、それぞれに対する f の値は次の通りです。

  • f(\{P_1\}) = 1
  • f(\{P_2\}) = 1
  • f(\{P_3\}) = 1
  • f(\{P_1, P_2\}) = 2
  • f(\{P_2, P_3\}) = 2
  • f(\{P_3, P_1\}) = 3
  • f(\{P_1, P_2, P_3\}) = 3

これらの和は 13 です。


入力例 2

4
1 4
2 1
3 3
4 2

出力例 2

34

入力例 3

10
19 -11
-3 -12
5 3
3 -15
8 -14
-9 -20
10 -9
0 2
-7 17
6 -6

出力例 3

7222

和を 998244353 で割った余りを出力することに注意してください。

Score : 600 points

Problem Statement

We have a set S of N points in a two-dimensional plane. The coordinates of the i-th point are (x_i, y_i). The N points have distinct x-coordinates and distinct y-coordinates.

For a non-empty subset T of S, let f(T) be the number of points contained in the smallest rectangle, whose sides are parallel to the coordinate axes, that contains all the points in T. More formally, we define f(T) as follows:

  • f(T) := (the number of integers i (1 \leq i \leq N) such that a \leq x_i \leq b and c \leq y_i \leq d, where a, b, c, and d are the minimum x-coordinate, the maximum x-coordinate, the minimum y-coordinate, and the maximum y-coordinate of the points in T)

Find the sum of f(T) over all non-empty subset T of S. Since it can be enormous, print the sum modulo 998244353.

Constraints

  • 1 \leq N \leq 2 \times 10^5
  • -10^9 \leq x_i, y_i \leq 10^9
  • x_i \neq x_j (i \neq j)
  • y_i \neq y_j (i \neq j)
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

N
x_1 y_1
:
x_N y_N

Output

Print the sum of f(T) over all non-empty subset T of S, modulo 998244353.


Sample Input 1

3
-1 3
2 1
3 -2

Sample Output 1

13

Let the first, second, and third points be P_1, P_2, and P_3, respectively. S = \{P_1, P_2, P_3\} has seven non-empty subsets, and f has the following values for each of them:

  • f(\{P_1\}) = 1
  • f(\{P_2\}) = 1
  • f(\{P_3\}) = 1
  • f(\{P_1, P_2\}) = 2
  • f(\{P_2, P_3\}) = 2
  • f(\{P_3, P_1\}) = 3
  • f(\{P_1, P_2, P_3\}) = 3

The sum of these is 13.


Sample Input 2

4
1 4
2 1
3 3
4 2

Sample Output 2

34

Sample Input 3

10
19 -11
-3 -12
5 3
3 -15
8 -14
-9 -20
10 -9
0 2
-7 17
6 -6

Sample Output 3

7222

Be sure to print the sum modulo 998244353.