Movies

AtCoder
IDawtf2025_b
Time4000ms
Memory256MB
Difficulty
Maroon's summer vacation lasts $N$ days from Day $1$ through Day $N$. During the vacation, $M$ movies numbered from $1$ through $M$ are scheduled to be screened, and movie $i$ can be watched from Day $L_i$ through Day $R_i$. For a subset $s$ of all movies, define $f(s)$ as follows: * $f(s)$ is the maximum number of movies in $s$ that can be watched throughout the vacation when he can watch at most one movie per day. Here, watching the same movie multiple times counts as one movie. There are $2^M$ possible sets for $s$. Find the sum, modulo $998244353$, of $f(s)$ over all of them. ## Constraints * $1 \leq N \leq 100$ * $1 \leq M \leq N \times (N+1) /2$ * $1 \leq L_i \leq R_i \leq N$ * $(L_i,R_i) \neq (L_j,R_j)$ ($i \neq j$) * All input values are integers. ## Input The input is given from Standard Input in the following format: $N$ $M$ $L_1$ $R_1$ $L_2$ $R_2$ $\vdots$ $L_M$ $R_M$ [samples]
Samples
Input #1
2 3
1 1
2 2
1 2
Output #1
11

$f(s)=|s|$ holds for most $s$. The only exception is $s={1,2,3}$, where $f(s)=2$. The sum of $f(s)$ over all $s$ is $11$.
Input #2
3 3
1 1
2 2
3 3
Output #2
12
Input #3
4 10
3 3
2 4
2 3
4 4
3 4
1 3
1 1
2 2
1 2
1 4
Output #3
3796
Input #4
7 20
1 3
4 5
3 3
3 5
1 4
4 7
2 3
1 7
6 7
4 6
2 4
6 6
3 6
2 5
7 7
3 4
2 2
5 5
2 6
1 2
Output #4
7113137
API Response (JSON)
{
  "problem": {
    "name": "Movies",
    "description": {
      "content": "Maroon's summer vacation lasts $N$ days from Day $1$ through Day $N$. During the vacation, $M$ movies numbered from $1$ through $M$ are scheduled to be screened, and movie $i$ can be watched from Day ",
      "description_type": "Markdown"
    },
    "platform": "AtCoder",
    "limit": {
      "time_limit": 4000,
      "memory_limit": 262144
    },
    "difficulty": "None",
    "is_remote": true,
    "is_sync": true,
    "sync_url": null,
    "sign": "awtf2025_b"
  },
  "statements": [
    {
      "statement_type": "Markdown",
      "content": "Maroon's summer vacation lasts $N$ days from Day $1$ through Day $N$. During the vacation, $M$ movies numbered from $1$ through $M$ are scheduled to be screened, and movie $i$ can be watched from Day ...",
      "is_translate": false,
      "language": "English"
    }
  ]
}
Full JSON Raw Segments