QOJ.ac

QOJ

时间限制: 10 s 内存限制: 1024 MB 总分: 100

#2589. Mr. Toluene's Scoreboard Rolling

统计

Mr. Toluene is building an online judge and has noticed that participants in contests are very concerned about their rankings. In an ACM-style contest, if the number of solved problems is different, the person with more solved problems is ranked higher. If the number of solved problems is the same, the person with less penalty time is ranked higher. Mr. Toluene would like you to help design a program that, every time someone solves a problem, tells them how many people are ranked ahead of them (excluding those who have the same number of solved problems and the same penalty time).

Input

The first line contains an integer $T$ representing the number of test cases. For each test case: input three integers $m, n, \text{seed}$. $m$ represents the total number of participants (numbered $1$ to $m$), and $n$ represents the total number of accepts (assuming accepts are already deduplicated, i.e., there are no duplicate submissions for the same problem by the same person). $\text{seed}$ represents the seed for data generation.

You are required to use the following function to generate the data:

typedef unsigned int ui ;
ui randNum ( ui& seed , ui l a s t , const ui m){
seed = seed * 17 + last;
return seed % m + 1 ;
}

(where last is the result of the previous output; if no output has been produced yet, last = 7)

For each of the $n$ submissions, generate two values $Ria$ and $Rib$, indicating that participant $Ria$ has accepted a problem with a penalty time of $Rib$. (This means $Ria$'s number of solved problems increases by $1$, and their total penalty time increases by $Rib$).

It is guaranteed that a total of $n$ sets of data are generated, representing $n$ total submissions. For all data, it is guaranteed that the sum of penalty times does not exceed $1,500,000$.

Output

For each submission, output one integer on a new line, representing how many participants have a higher score than $Ria$ after the current accept.

Constraints

Test Case # 1, 2 3, 4 5 6, 7, 8 9, 10
$T$ $\le 10$ $\le 5$ $\le 15$ $\le 5$ $\le 5$
$m$ $\le 1000$ $\le 10000$ $\le 10^5$ $\le 10^4$ $\le 10^5$
$n$ $\le 1000$ $\le 10000$ $\le 10^5$ $\le 10^6$ $\le 10^6$

Examples

Input 1

1
7 3 1

Output 1

0
1
0

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.