[USACO08JAN] Cow Contest S

题目描述

$N (1 ≤ N ≤ 100)$ cows, conveniently numbered $1 ~ N$ , are participating in a programming contest. As we all know, some cows code better than others. Each cow has a certain constant skill rating that is unique among the competitors. The contest is conducted in several head-to-head rounds, each between two cows. If cow $A$ has a greater skill level than cow $B (1 ≤ A ≤ N; 1 ≤ B ≤ N; A ≠ B)$, then cow $A$ will always beat cow $B$ . Farmer John is trying to rank the cows by skill level. Given a list the results of $M (1 ≤ M ≤ 4,500)$ two-cow rounds, determine the number of cows whose ranks can be precisely determined from the results. It is guaranteed that the results of the rounds will not be contradictory. FJ的 $N$（$1 \leq N \leq 100$）头奶牛们最近参加了场程序设计竞赛。在赛场上，奶牛们按 $1, 2, \cdots, N$ 依次编号。每头奶牛的编程能力不尽相同，并且没有哪两头奶牛的水平不相上下，也就是说，奶牛们的编程能力有明确的排名。 整个比赛被分成了若干轮，每一轮是两头指定编号的奶牛的对决。如果编号为 $A$ 的奶牛的编程能力强于编号为 $B$ 的奶牛 （$1 \leq A, B \leq N$，$A \neq B$)，那么她们的对决中，编号为 $A$ 的奶牛总是能胜出。 FJ 想知道奶牛们编程能力的具体排名，于是他找来了奶牛们所有 $M$（$1 \leq M \leq 4,500$）轮比赛的结果，希望你能根据这些信息，推断出尽可能多的奶牛的编程能力排名。比赛结果保证不会自相矛盾。

输入输出样例

输入样例 #1

5 5
4 3
4 2
3 2
1 2
2 5

输出样例 #1

2