当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

2443:Set Operation

题目描述
You are given N sets, the i-th set (represent by S(i)) have C(i) element (Here "set" isn't entirely the same as the "set" defined in mathematics, and a set may contain two same element). Every element in a set is represented by a positive number from 1 to 10000. Now there are some queries need to answer. A query is to determine whether two given elements i and j belong to at least one set at the same time. In another word, you should determine if there exist a number k (1 <= k <= N) such that element i belongs to S(k) and element j also belong to S(k).
输入解释
First line of input contains an integer N (1 <= N <= 1000), which represents the amount of sets. Then follow N lines. Each starts with a number C(i) (1 <= C(i) <= 10000), and then C(i) numbers, which are separated with a space, follow to give the element in the set (these C(i) numbers needn't be different from each other). The N + 2 line contains a number Q (1 <= Q <= 200000), representing the number of queries. Then follow Q lines. Each contains a pair of number i and j (1 <= i, j <= 10000, and i may equal to j), which describe the elements need to be answer.
输出解释
For each query, in a single line, if there exist such a number k, print "Yes"; otherwise print "No".
输入样例
3
3 1 2 3
3 1 2 5
1 10
4
1 3
1 5
3 5
1 10
输出样例
Yes
Yes
No
No
提示
The input may be large, and the I/O functions (cin/cout) of C++ language may be a little too slow for this problem.

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 POJ Monthly,Minkerui

源链接: POJ-2443

最后修改于 2020-10-29T06:32:36+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 65536