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$.

ضع النتائج في جدول وأجب مثلًا: «كم بقرة أجابت 2 للسؤال 3 و4 للسؤال 7 وأيضًا 1 للسؤال 8؟» الطلب له $P$ أجزاء ($1 \le P \le 10$)، كل جزء يحوي $Qj$ ($1 \le Qj \le NQ$) و$Aj$ ($1 \le Aj \le 5$)، رقم السؤال والجواب المطلوب. اطبع عددًا صحيحًا واحدًا، مجموع الأبقار التي أجابت $Aj$ عن $Qj$ لكل $j\in\{1,\ldots,P\}$.

لأربع أبقار وخمسة أسئلة تكون الإجابات:

البقرة / رقم السؤال $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$

لـ«كم بقرة أجابت 2 عن السؤال 1 و1 عن السؤال 2؟» الجواب 1، البقرة 4 فقط. ولـ«كم بقرة أجابت 1 عن السؤالين 1 و3؟» الجواب 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.