#P9403. [POI 2020/2021 R3] Les Bitérables

    ID: 10492 远端评测题 1000ms 256MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>2020POI(波兰)差分双指针 two-pointer

[POI 2020/2021 R3] Les Bitérables

Background

Translated from XXVIII Olimpiada Informatyczna - Stage III Les Bitérables.

d1t2。

Problem Description

There are tt moments. At moment ii, a configuration p1,p2,,psip_1, p_2, \dots, p_{s_i} is given, meaning that within the interval (0,d)(0, d) on the number line, items exist at and only at positions p1,p2,,psip_1, p_2, \dots, p_{s_i}.

At position 00 and position dd, there are infinitely many items.

You may pay a cost of 11 to move one item one position to the left or one position to the right.

For each pair of adjacent moments, ask for the minimum total cost needed to transform the previous configuration into the next configuration.

Input Format

The first line contains two positive integers n,dn, d.

The next nn lines each describe the configuration at one moment. Each line starts with a non-negative integer sis_i, followed by sis_i positive integers p1,p2,,psip_1, p_2, \dots, p_{s_i}. It is guaranteed that 0<p1<p2<<psi<d0 < p_1 < p_2 < \dots < p_{s_i} < d.

Output Format

Output n1n - 1 lines, each containing one integer: your answer.

3 10
2 4 7
3 3 6 8
1 5

4
6
见附件
6252500
6252500

见附件
999990000
999990000
999990000
999990000

生成器:/paste/3igmip11
生成器:/paste/fusadpm0

Hint

For all testdata, 2n5000002 \leq n \leq 500000, 2d10122 \leq d \leq 10^{12}, si500000\sum s_i \leq 500000.

Subtask ID Additional Constraints Score
1 si1s_i \leq 1 5
2 si3s_i \leq 3 10
3 d7d \leq 7 12
4 si5000\sum s_i \leq 5000 27
5 If si>0s_i > 0, then psi=p1+si1p_{s_i} = p_1 + s_i - 1 11
6 35

Translated by ChatGPT 5