A1362 | [COCI-2016_2017-contest7]#1 Baza
来源COCI
时间限制1s
内存限制128MB
通过 / 提交0/0
题目描述
Mirko got a summer internship in a big IT company. This company builds a large database consisting of N rows and M columns.
On his first day, Mirko received a total of Q queries. Each query consists of M numbers.
However, some numbers got lost during transition, so they are denoted with -
1. Mirko wants to know how many rows of the database correspond to the query, i.e., how many rows of the database have identical numbers as the query, excluding -
1.
For example, if the query is in the form of -1 3 2, then we need to count the rows of the database that have any number in the first column, have the number 3 in the second column, and have the number 2 in the third column.
Since he just started with his internship, Mirko needs your help. Help him and answer the queries!
On his first day, Mirko received a total of Q queries. Each query consists of M numbers.
However, some numbers got lost during transition, so they are denoted with -
1. Mirko wants to know how many rows of the database correspond to the query, i.e., how many rows of the database have identical numbers as the query, excluding -
1.
For example, if the query is in the form of -1 3 2, then we need to count the rows of the database that have any number in the first column, have the number 3 in the second column, and have the number 2 in the third column.
Since he just started with his internship, Mirko needs your help. Help him and answer the queries!
输入格式
The first line of input contains N (1 ≤ N ≤ 10^3) and M (1 ≤ M ≤ 10^3), the size of the database.
Each of the following N lines contains M numbers Aij (1 ≤ Aij ≤ 10^6), the content of the database.
The following line contains Q (1 ≤ Q ≤ 50), the number of queries.
Each of the following Q lines contains M numbers Bij (Bij = -1 or 1 ≤ Bij ≤ 10^6), the description of the i^th query.
Each of the following N lines contains M numbers Aij (1 ≤ Aij ≤ 10^6), the content of the database.
The following line contains Q (1 ≤ Q ≤ 50), the number of queries.
Each of the following Q lines contains M numbers Bij (Bij = -1 or 1 ≤ Bij ≤ 10^6), the description of the i^th query.
输出格式
The output must contain Q lines, each line containing X, the answer to the i^th query from the task.
输入输出样例
输入 #1
4 3 1 5 2 2 3 4 4 3 2 5 4 6 3 -1 -1 2 -1 3 2 -1 -1 -1
输出 #1
2 1 4
输入 #2
3 8 6 5 97 99 82 50 95 1 85 62 11 64 94 84 88 19 43 99 11 64 94 84 31 19 3 -1 -1 11 64 94 84 -1 19 -1 -1 -1 99 -1 -1 -1 1 95 -1 -1 -1 -1 80 -1 -1
输出 #2
2 1 0
Clarification of the first example:
The first query asks how many rows have the number 2 in the third column. These are rows number 1 (1
5 2) and number 3 (4 3 2).
The second query asks how many rows have the numbers 3 and 2 in the second and third column. This
is only row number 3 (4 3 2).
The third query asks how many rows are there in total, and the answer is obviously 4.
The first query asks how many rows have the number 2 in the third column. These are rows number 1 (1
5 2) and number 3 (4 3 2).
The second query asks how many rows have the numbers 3 and 2 in the second and third column. This
is only row number 3 (4 3 2).
The third query asks how many rows are there in total, and the answer is obviously 4.
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted