QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 256 MB Total points: 100

#22493. Club del libro

Statistics

Bessie cerca mucche per il club del libro. La mandria ne ha $N$ ($2 \le N \le 50,000$), numerate $1\ldots N$, ma vuole solo le più selettive e socievoli.

Come un servizio di incontri, crea un questionario e chiede a ciascuna delle $N$ mucche di rispondere alle $NQ$ domande ($1 \le NQ \le 50$), chiamate $R_{1}\ldots R_{NQ}$. Ad esempio: «Quanto ti piace leggere fantascienza?» Ogni risposta è un intero in $1\ldots 5$.

Tabula i risultati e rispondi, ad esempio: «Quante mucche hanno risposto 2 alla domanda 3, 4 alla 7 e 1 alla 8?» La richiesta ha $P$ parti ($1 \le P \le 10$), ciascuna con $Qj$ ($1 \le Qj \le NQ$) e $Aj$ ($1 \le Aj \le 5$), numero e risposta richiesta. Stampa un intero, il totale delle mucche che hanno risposto $Aj$ a $Qj$ per ogni $j\in\{1,\ldots,P\}$.

Per 4 mucche e 5 domande, le risposte sono:

Mucca / Numero della domanda $1$ $2$ $3$ $4$ $5$
$1$ $1$ $1$ $1$ $1$ $1$
$2$ $1$ $2$ $3$ $4$ $5$
$3$ $1$ $2$ $1$ $2$ $3$
$4$ $2$ $1$ $1$ $2$ $2$

Per «Quante hanno risposto 2 alla domanda 1 e 1 alla 2?» la risposta è 1, solo la mucca 4. Per «Quante hanno risposto 1 alle domande 1 e 3?» è 2, le mucche 1 e 3.

Input

  • Riga 1: tre interi separati da spazi: $N$, $NQ$ e $P$.
  • Righe $2\ldots N+1$: la riga $i+1$ contiene $NQ$ interi separati da spazi, risposte della mucca $i$: $R_{1}\ldots R_{NQ}$.
  • Righe $N+2\ldots N+1+P$: la riga $j+N+1$ contiene due interi separati da uno spazio: $Qj$ e $Aj$.

Output

  • Riga 1: un intero, il numero di mucche che soddisfano tutti i criteri di Bessie.

Esempi

Input 1

4 5 2
1 1 1 1 1
1 2 3 4 5
1 2 1 2 3
2 1 1 2 2
1 1
3 1

Output 1

2

Autore del problema: Rob Kolstad, 2010

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.