Logo
(追記) (追記ここまで)

30362번 - Distance Permutation 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
5 초 1024 MB331100.000%

문제

You construct a permutation $P = (P_1, P_2, \dots , P_{10^5})$ of length 10ドル^5$ in the following way.

The number line has points 1,ドル 2, \dots, 10^5$. The distance between points $i$ and $j$ is $|i-j|$. Also, there is a sequence $P$ that is initially empty. Repeat the following operations from any point until the length of $P$ is 10ドル^5$.

  • Let $x$ be the number corresponding to the current point. if $x$ is not in $P,ドル add $x$ to the end of $P$. Next, move to one of the points whose distance is less than or equal to $K$.

Answer the following $Q$ queries.

You are given integers $N,ドル $L,ドル $R$. Let the sequence created by removing elements larger than $N$ from $P$ be $P' = (P'_1, P'_2, \dots , P'_N)$. Among the possible permutations of $P',ドル answer the number of permutations in which $P'_1$ is greater than or equal to $L$ and less than or equal to $R$ with 998244353ドル$.

입력

$K$ $Q$

$\text{query}_1$

$\vdots$

$\text{query}_Q$

$\text{query}_i$ represents the $i$-th query.

Each query is given in the following format.

$N$ $L$ $R$

출력

Output $Q$ lines. On the $i$-th line, output the answer of the $i$-th query.

제한

  • All inputs consist of integers.
  • 1ドル \le Q \le 2 \times 10^5$
  • 1ドル \le K \le 10^5$
  • 1ドル \le N \le 10^5$
  • 1ドル \le L \le R \le N$

예제 입력 1

2 4
4 1 1
3 1 3
10 2 7
1 1 1

예제 출력 1

4
6
140172
1

예제 입력 2

314 6
60522 7560 25373
79445 26896 78962
33447 12441 21469
47202 17227 32455
63982 13450 41311
2156 1226 2148

예제 출력 2

925500464
455690352
567782656
893053639
942918900
458845228

힌트

In Sample Input 1, There are four possible sequences as $P'$ in the first query.

  • $(1, 2, 3, 4)$
  • $(1, 2, 4, 3)$
  • $(1, 3, 2, 4)$
  • $(1, 3, 4, 2)$

출처

Contest > ICPC Japanese Alumni Group > JAG Summer Camp > JAG Summer Camp 2023 Day 2 I번

Camp > Petrozavodsk Programming Camp > Summer 2024 > Day 1: Welcome Contest I번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /