QOJ.ac

QOJ

Limite de temps : 1 s Limite de mémoire : 1024 MB Points totaux : 100

#13246. rng

Statistiques

There is a sequence $a_1, a_2, \dots, a_n$ of length $n$, where each $a_i$ is a real number independently and uniformly generated from the interval $[l_i, r_i]$.

If $1 \le i < j \le n$ and $a_i > a_j$, we call $(i, j)$ an inversion. You need to find the expected number of inversions in this sequence. For simplicity, you only need to output the expected value modulo $998244353$.

Input

The first line contains a single positive integer $n$.

The next $n$ lines each contain two non-negative integers $l_i, r_i$.

Output

Output the expected number of inversions modulo $998244353$.

Examples

Input 1

3
2 3
4 5
1 6

Output 1

1

Subtasks

For all data, $0 \le l_i < r_i \le 10^8$.

  • Subtask 1 (20pts): $n \le 3$, $r_i \le 5$.
  • Subtask 2 (20pts): $n \le 10$.
  • Subtask 3 (20pts): $n \le 1000$.
  • Subtask 4 (20pts): $n \le 10^5$, $l_i = 0$.
  • Subtask 5 (20pts): $n \le 10^5$.

Editorials

IDTypeStatusTitlePosted ByLast UpdatedActions
EditorialOpen Official EditorialQingyu- Download

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.