uHunt
Time limit1sMemory limit128 MB
Process judge submissions in order and after each one report the leader's time and the submitter's rank by personal best, ignoring non-improving resubmissions.
- Level
Medium4 of 10
- Topics
- Sorting, Hash map, Simulation
- Solved
- No attempts yet
Problem
uHunt is short for "UVa Hunting". It is a tool for the UVa online judge that keeps track of which problems you have solved and shows statistics together with a list of problems to try next.
My brother Felix Halim built the site. The UVa online judge has collected about 9 million submissions so far, roughly one every few seconds, along with about 3000 different problems and about 120000 users. Probably only a few thousand of them are active right now. My brother had to optimize the tool very hard so that every feature finishes "in an instant".
This problem covers one small piece of uHunt, the instant re-ranking of accepted submissions. One of the values the UVa online judge ranks is the running time an accepted program spends on the judge data and the judge machine. Take problem 100. Four accepted submissions already exist for it, ranked like this.
Now user you submits accepted code for problem 100 and the judge measures 0.127 seconds. Then you takes the new rank 3, and felix and steven drop to rank 4 and rank 5. Even though you ties nhahtdh, nhahtdh set that time earlier and stays ahead.
Suppose you is unhappy with rank 3 and rewrites the code for problem 100. The new version carries more implementation tricks and is judged at 0.115 seconds, so you takes rank 1 while josh and nhahtdh drop to rank 2 and rank 3. felix and steven keep rank 4 and rank 5.
If another user grace submits accepted code for problem 100 with a running time of 3.475 seconds, the ranking becomes:
Suppose you tinkers some more and submits yet another accepted program for problem 100, judged at 0.121 seconds. That is slower than the personal best you already holds. The judge ignores such a submission, so the ranking stays exactly as in the table above.
Input
The first line contains (), the number of submissions. The submissions are sorted by the time they were made, and you have to process them one after another in that order.
Each of the next lines contains problem_id, user_id and t, separated by single spaces. problem_id is a 3 digit integer from 100 to 199. user_id is a 4 digit integer from 0000 to 9999, padded with leading zeros. t is the running time of the accepted code that user user_id submitted for problem problem_id. It is written in the d.ddd format with exactly three digits after the decimal point and lies between 0.000 and 9.999. The time limit of every problem is under 10 seconds, so t never exceeds 9.999.
Output
Print one line as soon as you read each input line.
If the running time of that submission is slower than or equal to the best time the same user already holds on the same problem, print submission ignored and do not let the submission change the ranking.
Otherwise print five values separated by single spaces. The first three, problem_id, user_id and t, repeat the input in exactly the format it was given. The fourth value is the running time of the rank 1 coder on this problem once the submission is applied, and the fifth value is the rank of this user on this problem once the submission is applied. Write both running times in the d.ddd format.
Ranks come from sorting the users who hold accepted code on that problem by their personal best in increasing order. When two personal bests are equal, the submission that set the time earlier comes first.