A8998 | Sereja and Bottles
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
Sereja and his friends went to a picnic. The guys had $n$ soda bottles just for it. Sereja forgot the bottle opener as usual, so the guys had to come up with another way to open bottles.
Sereja knows that the $i$ -th bottle is from brand $a_{i}$ , besides, you can use it to open other bottles of brand $b_{i}$ . You can use one bottle to open multiple other bottles. Sereja can open bottle with opened bottle or closed bottle.
Knowing this, Sereja wants to find out the number of bottles they've got that they won't be able to open in any way. Help him and find this number.
Sereja knows that the $i$ -th bottle is from brand $a_{i}$ , besides, you can use it to open other bottles of brand $b_{i}$ . You can use one bottle to open multiple other bottles. Sereja can open bottle with opened bottle or closed bottle.
Knowing this, Sereja wants to find out the number of bottles they've got that they won't be able to open in any way. Help him and find this number.
输入格式
The first line contains integer $n$ $(1<=n<=100)$ — the number of bottles. The next $n$ lines contain the bottles' description. The $i$ -th line contains two integers $a_{i},b_{i}$ $(1<=a_{i},b_{i}<=1000)$ — the description of the $i$ -th bottle.
输出格式
In a single line print a single integer — the answer to the problem.
输入输出样例
输入 #1
4 1 1 2 2 3 3 4 4
输出 #1
4
输入 #2
4 1 2 2 3 3 4 4 1
输出 #2
0
暂无题解
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted