QOJ.ac

QOJ

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

#22362. رسالة سرية

Statistics

تقود Bessie الأبقار في محاولة هروب! يرسلن رسائل ثنائية سرية لبعضهن.

اعترض Farmer John الذكي دائمًا كعميل مضاد للتجسس أول $b_{i}$ بت، $(1 \le b_{i} \le 10,000)$، لكل من $M$ رسائل، $(1 \le M \le 50,000)$.

جمع قائمة $N$ كلمات شفرة جزئية، $(1 \le N \le 50,000)$، يظن الأبقار تستخدمها. للأسف يعرف فقط أول $c_{j}$ بت للكلمة $j$، $(1 \le c_{j} \le 10,000)$.

لكل كلمة $j$ احسب عدد الرسائل المعترضة المطابقة، أي ذات البتات الأولية نفسها مع الكلمة.

مجموع بتات الإدخال، أي مجموع $b_{i}$ و$c_{j}$، لا يتجاوز $500,000$.

الإدخال

  • السطر $1$: العددان الصحيحان $M$ و$N$.

  • الأسطر $2,\ldots,M+1$: السطر $i+1$ يصف الرسالة $i$ بعدد صحيح $b_{i}$ ثم $b_{i}$ قيم 0 أو 1 مفصولة بمسافات.

  • الأسطر $M+2,\ldots,M+N+1$: السطر $M+j+1$ يصف الكلمة $j$ بعدد صحيح $c_{j}$ ثم $c_{j}$ قيم 0 أو 1 مفصولة بمسافات.

الإخراج

  • الأسطر $1,\ldots,M$: السطر $j$ عدد الرسائل التي قد تطابق الكلمة $j$.

أمثلة

الإدخال 1

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

الإخراج 1

1
3
1
1
2

ملاحظة

أربع رسائل وخمس كلمات. بدايات الرسائل 010 و1 و100 و110؛ الكلمات 0 و1 و01 و01001 و11.

0 تطابق فقط 010: $1$. 1 تطابق 1 و100 و110: $3$. 01 فقط 010: $1$. 01001 تطابق 010: $1$. 11 تطابق 1 و110: $2$.

مؤلفا المسألة: David Benjamin وJacob Steinhardt، 2008

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.