Submissions

시간 제한2초메모리 제한2048 MB

요약
제출 하나만 상태를 바꿀 수 있을 때 금메달을 받을 수 있는 팀을 모두 구한다.
난이도

어려움10점 중 8점

유형
정렬, 구현, 그리디, 해시맵
정답자
아직 제출이 없습니다

문제

The legend, example, and note of this problem are used fictitiously. Any resemblance to the actual contests, rules, submissions, or teams is coincidental.

In the International Challenging Puzzle Contest (ICPC), there are mm submissions. You are given the list of mm submissions ordered by time. A submission can be represented as a tuple (c,p,t,s)(c,p,t,s), which means team cc makes a submission on problem pp at time tt with status ss. The status of a submission is either "accepted" or "rejected".

The score of a team is the pair of the number of problems solved by the team and the total time consumed†^\dagger by the team. The larger the number of problems solved is, the higher the score is. If a tie occurs, the smaller the total time consumed is, the higher the score is.

If team cc makes at least one submission with status "accepted" on problem pp, we say that team cc solves problem pp. A team can get a gold medal if the number of teams with higher score is less than min⁡(⌈0.1⋅n⌉,35)\min(\lceil 0.1 \cdot n \rceil, 35), where nn is the number of teams that solved at least one problem and ⌈x⌉\lceil x \rceil denotes the smallest integer that is not smaller than xx.

You need to find all the teams that can get a gold medal if at most one of the mm submissions changes its status.

†\dagger The total time consumed is the sum of times consumed for all solved problems (00 if no problems are solved). The time consumed for a solved problem is the time of the first submission with status "accepted", plus 2020 times the number of submissions on this problem before the first submission with status "accepted". Note that we say submission ii is before submission jj if and only if submission ii appears earlier than submission jj in the given list of mm submissions.

입력

Each test contains multiple test cases. The first line contains a single integer tt (1≤t≤1051 \le t \le 10^5) denoting the number of test cases. For each test case:

The first line contains a single integer mm (1≤m≤1051 \le m \le 10^5) denoting the number of submissions.

The ii-th of the following mm lines contains c_ic\_i, p_ip\_i, t_it\_i, and s_is\_i which mean that team c_ic\_i makes a submission on problem p_ip\_i at time t_it\_i with status s_is\_i. Specifically:

  • c_ic\_i is a string of length between 11 and 2020 consisting of uppercase letters, lowercase letters, digits and underscores ('_'). Note that no two teams have the same name.
  • p_ip\_i is an uppercase letter.
  • t_it\_i is a non-negative integer less than 300300.
  • s_is\_i is a string, being either "accepted" or "rejected".

It is guaranteed that t_i≤t_jt\_i \le t\_j for all i<ji < j. Recall that if t_i=t_jt\_i = t\_j and i<ji < j, we still say that the ii-th submission came before the jj-th submission.

It is guaranteed that the sum of mm over all test cases does not exceed 10510^5.

출력

For each test case:

Output one integer kk on the first line, denoting the number of teams that can get a gold medal if at most one of the mm submissions changes its status.

On the second line, output kk distinct strings in any order, denoting the names of these kk teams.

힌트

In the first case of the first example, TS1 solves two problems, so they can get a gold medal. TSxingxing10 can get a gold medal if their first submission changes its status to "accepted".

In the second case of the first example, AllWayTheNorth, XuejunXinyoudui1, LetItRot and ImYourFan have the same score, two problems solved with 514514 total time consumed. They can get gold medals simultaneously if no submission changes its status.

예제4

  1. 예제 1

    입력
    2
    5
    TSxingxing10 G 0 rejected
    TSxingxing10 B 83 accepted
    aoliaoligeiliao J 98 accepted
    TS1 J 118 accepted
    TS1 B 263 accepted
    12
    AllWayTheNorth A 0 rejected
    YaoYaoLingXian Y 10 accepted
    XuejunXinyoudui1 X 200 rejected
    XuejunXinyoudui1 X 200 accepted
    LetItRot L 215 accepted
    AllWayTheNorth W 250 accepted
    ImYourFan I 257 accepted
    ImYourFan Y 257 accepted
    AllWayTheNorth T 264 accepted
    XuejunXinyoudui1 J 294 accepted
    LetItRot I 299 accepted
    LetItRot I 299 rejected
    
    예상 출력
    2
    TSxingxing10 TS1
    4
    AllWayTheNorth XuejunXinyoudui1 LetItRot ImYourFan
    
  2. 예제 2

    입력
    2
    2
    jiangly_fan A 1 accepted
    jiangly B 23 accepted
    3
    conqueror_of_tourist A 1 accepted
    conqueror_of_tourist A 2 accepted
    tourist B 23 accepted
    
    예상 출력
    2
    jiangly_fan jiangly
    1
    conqueror_of_tourist
    
  3. 예제 3

    입력
    2
    13
    A A 1 accepted
    A X 1 accepted
    K K 1 rejected
    B B 2 accepted
    C C 2 accepted
    D D 2 accepted
    E E 2 accepted
    F F 2 accepted
    G G 2 accepted
    H H 2 accepted
    I I 2 accepted
    J J 2 accepted
    K K 2 rejected
    12
    A A 1 accepted
    A X 1 accepted
    B B 2 accepted
    C C 2 accepted
    D D 2 accepted
    E E 2 accepted
    F F 2 accepted
    G G 2 accepted
    H H 2 accepted
    I I 2 accepted
    J J 2 rejected
    K K 2 rejected
    
    예상 출력
    11
    A K B C D E F G H I J
    1
    A
    
  4. 예제 4

    입력
    2
    11
    A A 1 accepted
    B B 1 accepted
    C C 2 accepted
    D D 2 accepted
    E E 2 accepted
    F F 2 accepted
    G G 2 accepted
    H H 2 accepted
    I I 2 accepted
    J J 2 accepted
    K K 2 accepted
    12
    A A 1 accepted
    A X 1 accepted
    K K 1 rejected
    B B 2 accepted
    C C 2 accepted
    D D 2 accepted
    E E 2 accepted
    F F 2 accepted
    G G 2 accepted
    H H 2 accepted
    I I 2 accepted
    J J 2 accepted
    
    예상 출력
    2
    A B
    2
    A K