knightnemo commited on
Commit
083d7b7
·
verified ·
1 Parent(s): bcf8ab5

Upload code_segments/segment_296.txt with huggingface_hub

Browse files
Files changed (1) hide show
  1. code_segments/segment_296.txt +37 -0
code_segments/segment_296.txt ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [NightHawk22 - Isolation](https://soundcloud.com/vepium/nighthawk22-isolation- official-limbo-remix)
2
+
3
+
4
+
5
+ This is the medium version of the problem. In the three versions, the constraints on $n$ and the time limit are different. You can make hacks only if all the versions of the problem are solved.
6
+
7
+ This is the statement of Problem D1B:
8
+
9
+ * There are $n$ cities in a row, numbered $1, 2, \ldots, n$ left to right. * At time $1$, you conquer exactly one city, called the starting city. * At time $2, 3, \ldots, n$, you can choose a city adjacent to the ones conquered so far and conquer it.
10
+
11
+ You win if, for each $i$, you conquer city $i$ at a time no later than $a_i$. A winning strategy may or may not exist, also depending on the starting city. How many starting cities allow you to win?
12
+
13
+ For each $0 \leq k \leq n$, count the number of arrays of positive integers $a_1, a_2, \ldots, a_n$ such that
14
+
15
+ * $1 \leq a_i \leq n$ for each $1 \leq i \leq n$; * the answer to Problem D1B is $k$.
16
+
17
+ The answer can be very large, so you have to calculate it modulo a given prime $p$.
18
+
19
+ Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 500$). The description of the test cases follows.
20
+
21
+ The only line of each test case contains two integers $n$, $p$ ($1 \le n \le 500$, $10^8 \leq p \leq 10^9$, $p$ is prime) — the number of cities and the modulo.
22
+
23
+ It is guaranteed that the sum of $n$ over all test cases does not exceed $500$.
24
+
25
+ For each test case, output $n+1$ integers: the $i$-th integer should be the number of arrays that satisfy the conditions for $k = i-1$.
26
+
27
+ In the first test case,
28
+
29
+ * arrays with $1$ good starting city: $[1]$.
30
+
31
+ In the second test case,
32
+
33
+ * arrays with $0$ good starting cities: $[1, 1]$; * arrays with $1$ good starting city: $[1, 2]$, $[2, 1]$; * arrays with $2$ good starting cities: $[2, 2]$.
34
+
35
+ In the third test case,
36
+
37
+ * arrays with $0$ good starting cities: $[1, 1, 1]$, $[1, 1, 2]$, $[1, 1, 3]$, $[1, 2, 1]$, $[1, 2, 2]$, $[1, 3, 1]$, $