A12115 | Determine Line
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Arkady's morning seemed to be straight of his nightmare. He overslept through the whole morning and, still half-asleep, got into the tram that arrived the first. Some time after, leaving the tram, he realized that he was not sure about the line number of the tram he was in.
During his ride, Arkady woke up several times and each time he saw the tram stopping at some stop. For each stop he knows which lines of tram stop there. Given this information, can you help Arkady determine what are the possible lines of the tram he was in?
During his ride, Arkady woke up several times and each time he saw the tram stopping at some stop. For each stop he knows which lines of tram stop there. Given this information, can you help Arkady determine what are the possible lines of the tram he was in?
输入格式
The first line contains a single integer $n$ ( $2 \le n \le 100$ ) — the number of stops Arkady saw.
The next $n$ lines describe the stops. Each of them starts with a single integer $r$ ( $1 \le r \le 100$ ) — the number of tram lines that stop there. $r$ distinct integers follow, each one between $1$ and $100$ , inclusive, — the line numbers. They can be in arbitrary order.
It is guaranteed that Arkady's information is consistent, i.e. there is at least one tram line that Arkady could take.
The next $n$ lines describe the stops. Each of them starts with a single integer $r$ ( $1 \le r \le 100$ ) — the number of tram lines that stop there. $r$ distinct integers follow, each one between $1$ and $100$ , inclusive, — the line numbers. They can be in arbitrary order.
It is guaranteed that Arkady's information is consistent, i.e. there is at least one tram line that Arkady could take.
输出格式
Print all tram lines that Arkady could be in, in arbitrary order.
输入输出样例
输入 #1
3 3 1 4 6 2 1 4 5 10 5 6 4 1
输出 #1
1 4
输入 #2
5 1 1 10 10 9 8 7 100 5 4 3 99 1 5 1 2 3 4 5 5 4 1 3 2 5 4 10 1 5 3
输出 #2
1
Consider the first example. Arkady woke up three times. The first time he saw a stop with lines $1$ , $4$ , $6$ . The second time he saw a stop with lines $1$ , $4$ . The third time he saw a stop with lines $10$ , $5$ , $6$ , $4$ and $1$ . He can be in a tram of one of two lines: $1$ or $4$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted