当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

3205:Ikki's Story II - War with TN

题目描述

Do you remember the war of my nation with TN?

If you don’t know that story, ask frkstyc to tell you. (And frkstyc says, “Please don’t ask me but refer to problem 2822 TN’s Kingdom IV – Collapse.”)

Once upon a time, I defeated the evil nation of TN! How did I do that?

Simple! The road network of the country of TN could be viewed as a directed graph, where each city is a vertex and there are edges between cities. And the capital s, is a distinguished vertex and every other vertex is reachable from s.

Well, let me see what happened at that time…

I wanted to destruct one particular city, t of the evil nation of TN. Since if I wanted to destroy t, TN would send troops from s to t to defend his nation. So I wanted to destroy all the cities (except s and t) that satisfy the following property:

All the paths from s to t would pass this city.

If all the cities with this property were destroyed and controlled by me, it would be quite certain that TN’s troops could not reach city t! Then it would be quite true that I would destroy city t relatively safely. :)

The evil nation was defeated because Ikki himself solved this problem! If you were Ikki, can you also solve this problem?

输入解释

The input contains exactly one test case.

The first line of the test case contains two integers N, M (N ≤ 10,000, M ≤ 100,000) which represent the number of cities and roads in the nation of TN, respectively.

M lines follow, each line contains two integers a, b, which means that there was a road from city a to city b (0 ≤ a, b < N). All the roads were directional.

Cities are numbered from 0 to N − 1, the capital is numbered 0.

The last line of each test case is an integer t, which is the city that Ikki was going to destroy.

输出解释

You should output one line consisting of only one integer K, denoting that there were K cities satisfying the property mentioned above.

输入样例
2 1
0 1
1
输出样例
0

该题目是Virtual Judge题目,来自 北京大学POJ

源链接: POJ-3205

最后修改于 2020-10-29T06:55:48+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
3000 131072