#P8843. [传智杯 #4 初赛] 萝卜数据库
[传智杯 #4 初赛] 萝卜数据库
Problem Description
Chipmunks really like to sneak and eat the production team’s big carrots, so Huālìshǔ Tech University is studying a new type of database called the Carrot Database.
More specifically, it supports fields (). Each field name is an integer, and the value stored in it is also an integer.
Now you need to support the following operations:
-
Insert a record into the database. It may contain only a subset of the fields. The exact operation format is described in “Input Format”.
-
Query how many records in the database satisfy a given condition.
You will perform a total of operations (). For each query operation, output the result.
Input Format
The first line contains two integers , with meanings as described above.
Each of the following lines represents one operation, as follows:
-
: indicates an insertion operation. There are fields. The name of the -th field is , and its value is . Here we guarantee that , , and both and are integers.
-
: indicates a query operation. It asks how many records satisfy that the value of field is within .
Output Format
For each query operation, output one line with one integer, representing the number of records that satisfy the condition.
4 5
1 2 1 2 2 4
2 2 1 5
1 2 3 5 4 6
2 4 7 8
1
0
Hint
Translated by ChatGPT 5