問題一覧 > 通常問題

No.801 Elevator

レベル : / 実行時間制限 : 1ケース 2.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 220
作問者 : tempura_pp / テスター : heno239
お気に入りにしたユーザー ProblemId : 2813 / 自分の提出
問題文最終更新日: 2019-03-17 20:10:47
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 208 (順位表) の他の問題:

Problem Statement

Tempura-kun is on the 1st floor of a building with $N$ floors. This building has $M$ elevators, numbered from 1 to $M$, each with a distinct number. Elevator $i$ stops at each floor from floor $L_i$ to floor $R_i$. Tempura-kun made exactly $k$ moves using these elevators. Here, one "move" specifically means the following procedure.

  • Letting $x$ be the current floor, choose one elevator $i$ satisfying $L_i \le x \le R_i$, ride elevator $i$, and get off at floor $y$ satisfying $L_i \le y \le R_i$. Note that $x=y$ is allowed, and in this case he is also regarded as having ridden elevator $i$.
Find the number of ways of moving such that Tempura-kun is on floor $N$ after $k$ moves, modulo $10^9+7$. Here, two ways of moving are considered different if at least one of the following two conditions holds.
  • There exists some $j$ such that the elevators ridden in the $j$-th move are different.
  • There exists some $j$ such that the floors he is on after the $j$-th move are different.

Apologies

With the writer's poor knowledge, the solution got TLE when written in Python3. The same code submitted in PyPy3 got AC (about 900 ms).

Input

$N\ M\ K$
$L_1\ R_1$
$L_2\ R_2$
$\vdots$
$L_M\ R_M$

  • $1\le N,\ M,\ K\le 3000$
  • $1\le L_i \le R_i \le N$
  • All inputs are integers.

Output

Output the number of ways of moving, modulo $10^9+7$, on one line.

Sample

Sample 1
Input
2 2 2
1 2
1 2
Output
8

Writing $(i, j)$ for riding elevator $i$ and moving to floor $j$, the following 8 ways satisfy the condition.

  • (1, 1), (1, 2)
  • (1, 1), (2, 2)
  • (2, 1), (1, 2)
  • (2, 1), (2, 2)
  • (1, 2), (1, 2)
  • (1, 2), (2, 2)
  • (2, 2), (1, 2)
  • (2, 2), (2, 2)
Note that he may ride an elevator without actually changing floors, and that there may be multiple elevators with the same capabilities.

Sample 2
Input
5 1 5
2 2
Output
0

There is no elevator he can board from floor 1, nor any elevator he can get off from at floor 5.
Is there any point to an elevator that cannot move from floor 2?

Sample 3
Input
8 6 10
2 7
1 8
2 8
1 8
2 8
4 6
Output
70138606

Answer modulo $10^9+7$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。