#P16999. [NWERC 2019] Average Rank

    ID: 19289 远端评测题 5000ms 512MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>模拟2019线性数据结构Special JudgeICPC

[NWERC 2019] Average Rank

Problem Description

:::align{center}

:::

The National Weekly Escape Room Challenge (NWERC) is a long-running competition held in Eindhoven. Every week a new escape room is presented, and anyone who completes it in their first attempt gains one point.

At the end of each week, competitors are ranked by the total number of points accumulated so far, highest first. In case of a tie, they share the same rank. In other words, the rank of a competitor is one more than the number of people with a strictly larger number of points.

In total there have been nn participants in the contest, and the contest has been going for ww weeks. For each week you are given a list of the competitors that gained a point that week. Your task is to calculate the average rank during the ww-week competition for each competitor.

Figure Figure illustrates the score progression in the third sample.

Input Format

The input consists of:

  • One line with two integers nn and ww (1n,w31051 \le n, w \le 3 \cdot 10^5), the number of competitors and the number of weeks. The competitors are numbered from 11 to nn.

  • ww lines (one for each week), each containing an integer kk (0kn0 \le k \le n) followed by kk distinct integers c1,,ckc_1, \ldots, c_k (1cin1 \le c_i \le n for all ii), indicating that the kk competitors c1,,ckc_1, \ldots, c_k each gained a point that week.

The total number of points awarded is at most 11 million.

Output Format

Output nn lines, the iith of which contains the average rank of the iith competitor during the ww-week competition. Your answers should have an absolute or relative error of at most 10610^{-6}.

3 2
2 1 2
2 1 3
1.000000
1.500000
2.500000
3 1
0
1.000000
1.000000
1.000000
5 6
2 3 5
2 3 1
0
3 3 5 2
3 5 4 2
2 3 4
3.166666667
3.333333333
1.000000000
3.833333333
1.666666667