CF315A.Sereja and Bottles
普及/提高-
通过率:0%
时间限制:2.00s
内存限制:256MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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.
谢列亚和他的朋友们去野餐。他们为此准备了 n 瓶汽水。谢列亚像往常一样忘记带开瓶器,因此大家不得不想出另一种开瓶的方法。
谢列亚知道第 i 瓶汽水的品牌为 ai,此外,它还可以用来开启其他品牌为 bi 的瓶子。一个瓶子可以用来开启多个其他瓶子。谢列亚可以用已开启的瓶子或未开启的瓶子来开启其他瓶子。
根据以上信息,谢列亚希望算出他们所拥有的、无论如何都无法开启的瓶子数量。请你帮助他求出这个数值。
输入格式
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.
第一行包含一个整数 n(1≤n≤100)—— 瓶子的数量。接下来的 n 行描述了各个瓶子。第 i 行包含两个整数 ai、bi(1≤ai,bi≤1000)—— 第 i 个瓶子的描述。
输出格式
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
输入解题思路,AI测评打分。不知道怎么写?