QOJ.ac

QOJ

حد الوقت: 4 s حد الذاكرة: 256 MB مجموع النقاط: 100

#93. 困惑

الإحصائيات

Sasha 住在宿舍里,他有很多东西。在暑假离开之前,他面临着打包行李的问题。Sasha 有 $B$ 个盒子,$T$ 种物品,$N$ 个这些类型的物品,以及 $Q$ 次操作。请帮助他处理所有操作。操作分为两类:

  1. 查询 $k$ 号盒子中有多少个 $t$ 类型的物品。
  2. 从 $k$ 号盒子的顶部取出 $n$ 个物品,并将其中所有 $t$ 类型的物品放入 $m$ 号盒子的顶部。

输入格式

第一行包含两个整数:$N$ ($1 \le N \le 10^5$),$T$ ($1 \le T \le 10^5$)。 第二行包含一个整数 $B$ ($1 \le B \le 10^5$)。 接下来的 $B$ 行描述每个盒子。每行以一个整数 $n$ ($0 \le n \le 10^5$) 开头,表示该盒子中物品的数量。接下来的 $n$ 个整数描述了从底部到顶部的物品类型。保证所有盒子中物品的总数等于 $N$。 下一行包含一个整数 $Q$ ($1 \le Q \le 10^5$)。 接下来的 $Q$ 行包含操作描述。首先是操作类型 $z$。如果 $z = 1$,则该行包含两个整数:$t$ ($1 \le t \le T$),$k$ ($1 \le k \le B$)。如果 $z = 2$,则该行包含四个整数:$t$ ($1 \le t \le T$),$k$ ($1 \le k \le B$),$n$ ($0 \le n \le 10^5$),$m$ ($1 \le m \le B, m \neq k$)。保证 $k$ 号盒子中的物品数量不少于 $n$。

输出格式

对于每种第一类型的操作,请在单独的行中输出答案。

样例

输入格式 1

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

输出格式 1

2
1
1
2

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.