問題一覧 > 通常問題

No.2338 Range AtCoder Query

レベル : / AI推定難易度 : 1750 / 実行時間制限 : 1ケース 4.000秒 / メモリ制限 : 512 MB / 標準ジャッジ問題
タグ : (AC するまで非表示) / 解いたユーザー数 54
作問者 : SSRS / テスター : 👑 Forested 👑 Nachia
お気に入りにしたユーザー ProblemId : 5985 / 自分の提出
問題文最終更新日: 2023-06-02 22:07:40
This statement was translated by AI (claude-opus-5-5, effort medium) and may contain errors or differ in nuance from the original. The original statement takes precedence. Back to the original
yukicoder contest 391 (順位表) の他の問題:

Problem Statement

You are given a sequence $P_1, P_2, \dots, P_N$ of length $N$ and $N$ strings $S_1, S_2, \dots, S_N$. Here, $S_i$ ($1 \leq i \leq N)$ is AC or WA.

You are given $Q$ queries; process them.

In the $i$-th query ($1 \leq i \leq Q$), you are given integers $L_i, R_i$. Solve the following problem.

Takahashi participated in a programming contest consisting of $M$ problems and made $R_i-L_i+1$ submissions during the contest.

The $j$-th submission ($1 \leq j \leq R_i-L_i+1$) was made to problem $P_{L_i+j-1}$, and its result was $S_{L_i+j-1}$.

Takahashi's number of correct answers is the number of problems for which he got AC at least $1$ time.

Takahashi's number of penalties is the sum, over all problems for which he got AC at least $1$ time, of the number of WA submissions before the first AC submission to that problem.

Find Takahashi's number of correct answers and number of penalties.

Input

The input is given from Standard Input in the following format.

$N$ $M$ $Q$
$P_1$ $S_1$
$P_2$ $S_2$
$\vdots$
$P_N$ $S_N$
$L_1$ $R_1$
$L_2$ $R_2$
$\vdots$
$L_Q$ $R_Q$

Output

Print $Q$ lines to Standard Output. On the $i$-th line ($1 \leq i \leq Q$), print Takahashi's number of correct answers and number of penalties for query $i$, in this order, separated by a space.
End the output with a newline.

Constraints

The input satisfies the following constraints.

  • $1 \leq N \leq 200\,000$
  • $1 \leq M \leq 200\,000$
  • $1 \leq Q \leq 200\,000$
  • $1 \leq P_i \leq M$ ($1 \leq i \leq N)$
  • $S_i$ ($1 \leq i \leq N$) is AC or WA.
  • $1 \leq L_i \leq R_i \leq N$ ($1 \leq i \leq Q)$
  • $N,M,Q,P_i,L_i,R_i$ are all integers.

Sample

Sample 1
Input
5 5 5
3 WA
3 AC
2 AC
5 WA
2 WA
1 2
3 3
2 4
2 5
1 5
Output
1 1
1 0
2 0
2 0
2 1

In query $1$, the only problem for which Takahashi got AC at least $1$ time is problem $3$, so the number of correct answers is $1$. He also got WA $1$ time before his first AC on problem $3$, so the number of penalties is $1$.

In query $2$, the only problem for which Takahashi got AC at least $1$ time is problem $2$, so the number of correct answers is $1$. He also got no WA before his first AC on problem $2$, so the number of penalties is $0$.

In query $3$, the problems for which Takahashi got AC at least $1$ time are problems $2$ and $3$, so the number of correct answers is $2$. He also got no WA before his first AC on problems $2$ and $3$, so the number of penalties is $0$.

In query $4$, the problems for which Takahashi got AC at least $1$ time are problems $2$ and $3$, so the number of correct answers is $2$. He also got no WA before his first AC on problems $2$ and $3$, so the number of penalties is $0$.

In query $5$, the problems for which Takahashi got AC at least $1$ time are problems $2$ and $3$, so the number of correct answers is $2$. He also got WA $0,1$ times, respectively, before his first AC on problems $2$ and $3$, so the number of penalties is $1$.

提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。