![](http://img.atcoder.jp/assets/top/img/flag-lang/ja.png)
![](http://img.atcoder.jp/assets/top/img/flag-lang/en.png)
Time Limit: 2 sec / Memory Limit: 1024 MB
配点 : 8 点
問題文
AtCoder 上で行われたあるコンテストにおいては、問題 A
, B
, C
, D
, E
, F
の 6 問の問題が出題され、全部で N 件の提出がありました。
N 件の提出はすべて異なる時刻に行われ、提出された時間が早いものから順に 1 , 2, \ldots , N と ID がつけられました。
また、全ての提出の結果は AC
または WA
であり、全ての問題について、その問題に対する提出であって、 結果が AC
であるようなものが 1 件以上存在しました。
具体的には、 ID が i である提出は問題 P_i ( P_i は A
, B
, C
, D
, E
, F
のいずれか ) に対する提出であり、その提出結果は V_i ( V_i は AC
, WA
のいずれか ) でした。
問題 A から問題 F までの各問題について、その問題を最初に AC
した提出の ID 、
すなわちその問題に対する提出で結果が AC
であるようなものであって、
提出 ID が最小であるようなものを求めてください。
制約
- 6 \leq N\leq 1000
- P_i は
A
,B
,C
,D
,E
,F
のいずれか - V_i は
AC
,WA
のいずれか - 各問題について、結果が
AC
であるような提出が 1 つ以上存在する。
入力
入力は以下の形式で標準入力から与えられる。
N P_1 V_1 P_2 V_2 : P_N V_N
出力
6 行出力せよ。
1 行目には、問題 A
を最初に AC
した提出の ID 、
2 行目には、問題 B
を最初に AC
した提出の ID 、
:
6 行目には、問題 F
を最初に AC
した提出の ID
を出力せよ。
入力例 1
8 A AC B WA C AC B AC A AC D AC E AC F AC
出力例 1
1 4 3 6 7 8
問題 A
, B
, C
に対する提出は最初の 5 つであり、それぞれについては以下の通りです。
- ID 1 の提出は問題
A
をAC
しており、これが問題A
の最初のAC
です。 - ID 2 の提出は問題
B
に対する提出ですが、WA
のため、これは問題B
の最初のAC
ではありません。 - ID 3 の提出は問題
C
をAC
しており、これが問題C
の最初のAC
です。 - ID 4 の提出は問題
B
をAC
しており、これが問題B
の最初のAC
です。 - ID 5 の提出は問題
A
をAC
していますが、 ID 1 の提出がすでに問題A
をAC
しているため、これは問題A
の最初のAC
ではありません。
これらと問題 D
, E
, F
に対する提出をあわせて、各問題を最初に AC
した提出の ID はそれぞれ、 1 , 4 , 3 , 6 , 7 , 8 となります。
Score : 8 points
Problem Statement
In some contest hold on AtCoder, there were 6 problems: A
, B
, C
, D
, E
, and F
, and a total of N submissions.
These N submissions, which were all made at distinct times, got assigned IDs 1, 2, \ldots, N in chronological order.
The verdict of every submission is AC
or WA
, and for every problem, there was at least one submission with the verdict AC
.
Specifically, the submission with ID i is a submission to Problem P_i (where P_i is A
, B
, C
, D
, E
, or F
), with the verdict V_i (where V_i is AC
or WA
).
For each problem from A through F, find the ID of the first submission that got AC
on that problem, that is, find the submission with the minimum ID among the ones made to that problem that got the verdict AC
.
Constraints
- 6 \leq N\leq 1000
- P_i is
A
,B
,C
,D
,E
, orF
. - V_i is
AC
orWA
. - For each problem, there is at least one submission with the verdict
AC
.
Input
Input is given from Standard Input in the following format:
N P_1 V_1 P_2 V_2 : P_N V_N
Output
Print 6 lines.
The 1-st line should contain the ID of the first submission that got AC
on Problem A
.
The 2-nd line should contain the ID of the first submission that got AC
on Problem B
.
:
The 6-th line should contain the ID of the first submission that got AC
on Problem F
.
Sample Input 1
8 A AC B WA C AC B AC A AC D AC E AC F AC
Sample Output 1
1 4 3 6 7 8
The first five submissions were made to Problems A
, B
, and C
, as follows.
- The submission with the ID 1 got
AC
on ProblemA
, which was the firstAC
on this problem. - The submission with the ID 2 was made to Problem
B
but gotWA
, so this was not the firstAC
on this problem. - The submission with the ID 3 got
AC
on ProblemC
, which was the firstAC
on this problem. - The submission with the ID 4 got
AC
on ProblemB
, which was the firstAC
on this problem. - The submission with the ID 5 got
AC
on ProblemA
, but the submission with the ID 1 already gotAC
on this problem, so this was not the firstAC
on it.
Summing up these and the submissions to Problems D
, E
, F
, the IDs of the first submissions that got AC
on the respective problems are 1, 4, 3, 6, 7, 8.