C题看了1个小时都看不懂。。
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 ai, besides, you can use it to open other bottles of brand bi. 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 ai,bi (1≤ai,bi≤1000) — the description of the i-th bottle.
In a single line print a single integer — the answer to the problem.
1 1
2 2
3 3
4 4
1 2
2 3
3 4
4 1
#include <iostream>
。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
Sereja has got an array, consisting of n integers, a1,a2,...,an. Sereja is an active boy, so he is now going to complete m operations. Each operation will have one of the three forms:
- Make vi-th array element equal to xi. In other words, perform the assignment avi=xi.
- Increase each array element by yi. In other words, perform n assignments ai=ai+yi (1≤i≤n).
- Take a piece of paper and write out the qi-th array element. That is, the element aqi.
Help Sereja, complete all his operations.
The first line contains integers n, m (1≤n,m≤105). The second line contains n space-separated integers a1,a2,...,an (1≤ai≤109) — the original array.
Next m lines describe operations, the i-th line describes the i-th operation. The first number in the i-th line is integer ti (1≤ti≤3) that represents the operation type. If ti=1, then it is followed by two integers vi and xi, (1≤vi≤n,1≤xi≤109). If ti=2, then it is followed by integer yi (1≤yi≤104). And if ti=3, then it is followed by integer qi (1≤qi≤n).
For each third type operation print value aqi. Print the values in the order, in which the corresponding queries follow in the input.
1 2 3 4 5 6 7 8 9 10
3 2
3 9
2 10
3 1
3 10
1 1 10
2 10
2 10
3 1
3 10
3 9
9
11
20
30
40
39