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

ל־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$

אם שואלים ״כמה ענו 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.