QOJ.ac

QOJ

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

#22493. 读书会

Statistics

Bessie 正在为读书会寻找成员。牛群有 $N$($2 \le N \le 50,000$)头奶牛,编号为 $1\ldots N$,但她只想招收最有鉴赏力、最善于社交的奶牛。

于是,她像交友服务一样制作了问卷,让 $N$ 头奶牛各自回答 $NQ$($1 \le NQ \le 50$)道题,题目名为 $R_{1}\ldots R_{NQ}$。题目例如“你有多喜欢阅读科幻小说?”,每个答案是 $1\ldots 5$ 范围内的整数。

你要统计问卷结果,回答这样的简单问题:“有多少头奶牛在第 3 题回答 2、第 7 题回答 4,并且第 8 题回答 1?”问题含 $P$($1 \le P \le 10$)个条件,每个条件有 $Qj$($1 \le Qj \le NQ$)和 $Aj$($1 \le Aj \le 5$),分别表示题号与要求的答案。程序输出一个整数,表示对所有 $j\in\{1,\ldots,P\}$ 都在 $Qj$ 题回答 $Aj$ 的奶牛总数。

考虑只有 4 头奶牛和 5 道题的问卷,答案如下:

奶牛 / 题号 $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$

若问“有多少头奶牛在第 1 题回答 2、第 2 题回答 1?”,答案为 1,只有 4 号奶牛。若问“有多少头奶牛在第 1 题和第 3 题都回答 1?”,答案为 2,是 1 号和 3 号奶牛。

输入格式

  • 第 1 行:三个空格分隔的整数 $N$、$NQ$ 和 $P$。
  • 第 $2\ldots N+1$ 行:第 $i+1$ 行包含 $NQ$ 个空格分隔的整数,是奶牛 $i$ 的答案 $R_{1}\ldots R_{NQ}$。
  • 第 $N+2\ldots N+1+P$ 行:第 $j+N+1$ 行包含两个空格分隔的整数 $Qj$ 和 $Aj$。

输出格式

  • 第 1 行:一个整数,表示满足 Bessie 所有条件的奶牛数量。

样例

输入格式 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

输出格式 1

2

题目作者: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.