#P3892. [GDOI2014] OJ

[GDOI2014] OJ

Description

Xiao M is a diligent ACMer. He has solved many problems in his spare time. But he is very forgetful and often forgets which problems he has solved, so he wants to write an OJ to manage the problems he has done.

After a week of effort, Xiao M’s OJ is basically finished, except for a Contest module that has not been implemented. Xiao M thinks this module is hard to implement, so he wants you to help.

Xiao M tells you that the basic elements of an OJ include:

  1. Problem, uniquely identified by pid, where pid is a positive integer.
  2. Contest, uniquely identified by cid, where cid is a positive integer.
  3. User, uniquely identified by uid, where uid is a positive integer.
  4. Submission status, uniquely identified by sid, where sid is a positive integer.

A submission status consists of sid, cid, pid, uid, and result, representing the submission ID of this entry, the contest ID it belongs to, the problem ID, the user ID, and the judging result.

For simplicity, result has only three states: AC, UNAC, and WAIT, meaning accepted, not accepted, and waiting for judge, respectively.

Meanwhile, the contest module needs to support the following requests:

  1. createContest cid t pid_1 pid_2 … pid_t

This creates a contest. The cid is a positive integer and is the unique identifier of this contest.

Here tt indicates there are tt problems (1t10001 \le t \le 1000) in this contest, followed by tt distinct integers denoting the problem IDs of this contest.

  1. submission sid cid pid uid result

The sid of this status either has not appeared before, or it has appeared before but was rejudged.

The result is AC or UNAC.

  1. getRank cid uid

In a contest, all users who have any submission should be included in the ranking (including submissions that have been rejudged). Users are ranked by the number of solved problems in descending order; if the solved count is the same, the tie-breaking is random.

This command needs to report the number of problems solved by user uid in contest cid, their best possible rank and worst possible rank.

Note that multiple accepted records on the same problem by user uid in contest cid count only once.

The output format is: uid solved highest lowest.

These represent the user ID, solved problem count, highest rank, and lowest rank, with highestlowest\mathit{highest} \le \mathit{lowest}.

  1. rejudge sid

Rejudge the submission identified by sid, i.e., set its result to WAIT.

Input Format

The first line contains three integers pcnt\mathit{pcnt}, ucnt\mathit{ucnt}, and mm ($1 \le \mathit{pcnt} \le 5000, 1 \le \mathit{ucnt} \le 5000, 1 \le m \le 3 \times 10^5$), indicating that the OJ has pcnt\mathit{pcnt} problems, ucnt\mathit{ucnt} users, and mm requests.

The range of pid is 10001000+pcnt11000 \sim 1000+\mathit{pcnt}-1, the range of uid is 1ucnt1 \sim \mathit{ucnt}, the range of cid is 1501 \sim 50, and 1sidm1 \le \mathit{sid} \le m.

Then there are mm lines, each containing one request, which is one of the four types described above. Requests should be executed in the input order.

You should note the following:

  1. For a createContest request, cid will not duplicate any previous createContest’s cid.
  2. For a submission request, before this request, the contest cid has already been created, and pid is one of the problems in that contest.
  3. For a getRank request, before this request, the contest cid has already been created, and user uid has at least one submission record in that contest.
  4. For a rejudge request, before this request, a submission identified by sid exists.

Output Format

For each getRank request, output the user ID, solved problem count, highest rank, and lowest rank, separated by single spaces.

7 5 17
createContest 1 5 1001 1004 1002 1005 1006
submission 1 1 1001 1 AC
submission 2 1 1001 1 AC
submission 3 1 1001 2 UNAC
submission 4 1 1003 3 UNAC
getRank 1 1
getRank 1 2
getRank 1 3
rejudge 3
submission 3 1 1001 2 AC
getRank 1 2
submission 5 1 1006 2 AC
getRank 1 1
submission 6 1 1006 2 UNAC
getRank 1 2
rejudge 5
getRank 1 2

1 1 1 1
2 0 2 3
3 0 2 3
2 1 1 2
1 1 2 2
2 2 1 1
2 1 1 2

Hint

For 20%20\% of the testdata, 1pcnt,ucnt,m1001 \le \mathit{pcnt}, \mathit{ucnt}, m \le 100.

For 50%50\% of the testdata, $1 \le \mathit{pcnt}, \mathit{ucnt} \le 2000, 1 \le m \le 50000$.

For 100%100\% of the testdata, $1 \le \mathit{pcnt}, \mathit{ucnt} \le 5000, 1 \le m \le 3 \times 10^5, 1 \le \mathit{cid} \le 50$.

Translated by ChatGPT 5