#Q96. 「一本通 3.5 练习 2」消息的传递
「一本通 3.5 练习 2」消息的传递
Description
Our esteemed Guo Jia is living a carefree life under Cao Cao's patronage. However, one day Cao Cao assigned him a mission: within Jianye City, there are spies of Yuan Shao, numbered from to . There exists a transmission relationship among them—if , then spy can directly pass a message to spy .
Now, Cao Cao wants to spread a false message to all the spies. Our task is to determine the minimum number of spies Guo Jia needs to inform initially so that the message reaches every spy.
Input Format
The first line of the input contains . The next lines form an matrix (where the -th row and -th column being means spy can directly pass a message to spy , and means spy cannot directly pass a message to spy ).
Output Format
The output consists of a single line: the minimum number of spies Guo Jia needs to inform initially.
Sample 1
8
0 0 1 0 0 0 0 0
1 0 0 1 0 0 0 0
0 1 0 1 1 0 0 0
0 0 0 0 0 1 0 0
0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 0
0 0 0 1 0 0 0 1
0 0 0 0 0 0 1 0
2
Constraints & Hints