A counting problem
Practice
4 (1 votes)
Datastructures
Dynamic programming
Algorithms
Medium
Problem
74% Success 333 Attempts 30 Points 1.5s Time Limit 512MB Memory 1024 KB Max Code

You have been given an integer $$N$$ and $$N$$ segments $$[L_i,R_i] \hspace{0.2cm} 1 \le i \le N $$. Now, we call a set of distinct integers $$ \{ k_1 , k_2,... , k_x \}, \hspace{0.2cm} 1 \le k_i \le N$$ good, if it is possible to arrange the integers in the set in some particular order to form a sequence $$ c_1, c_2 ... c_x $$, such that :

The Segment with index $$c_i $$ contains segment with index $$c_{i-1}, \forall \hspace{0.2cm} 2 \le i \le x $$. Segments are indexed by the order in which they appear in the input, beggining with $$1$$.

A segment $$[L_x,R_x]$$ is said to contain a segment $$[L_y,R_y]$$, if $$ L_x \le L_y $$ and $$ R_x \ge R_y $$. Now, for each $$j$$ from $$1$$ to $$N$$, you need find the number of good subsets of size $$j$$.

Print these numbers in increasing order of $$j$$. As these numbers can be rather large, print them Modulo $$998244353$$, a widely used prime.

Input Format :

The first line contains a single integer $$N$$. Each of the next $$N$$ lines contain $$2$$ space separated integers, where the $$2$$ integers on the $$i^{th}$$ line denote $$L_i,R_i $$.

Output Format

Print $$N$$ space separated integers. Note that all the integers need to be printed Modulo $$ 998244353 $$

Constraints :

$$ 1 \le N \le 3000 $$

$$ 1 \le L_i \le R_i \le 2 \cdot 10^9 $$

Please login to use the editor

You need to be logged in to access the code editor

Loading...

Please wait while we load the editor

Loading...
Results
Custom Input
Run your code to see the output
Submissions
Please login to view your submissions
Similar Problems
Points:30
Points:30
5 votes
Tags:
Dynamic ProgrammingGreedy algorithmAlgorithmsBinary SearchDatastructures
Points:30
19 votes
Tags:
DatastructuresQueryDynamic ProgrammingAlgorithmsMemoization