Nộp bài | Các bài nộp | Làm tốt nhất | Về danh sách bài |
ASSASSIN - Assassin Creed |
Ezio needs to kill N targets located in N different cities. The cities are connected by some one way roads. As time is short, Ezio can send a massage along with the map to the assassin's bureau to send some assassins who will start visiting cities and killing the targets. An assassin can start from any city, he may visit any city multiple times even the cities that are already visited by other assassins. Now Ezio wants to find the minimum number of assassins needed to kill all the targets.
Input
Input starts with an integer T (≤ 70), denoting the number of test cases.
Each case starts with a blank line. Next line contains two integers N (1 ≤ N ≤ 1000) and M (0 ≤ M ≤ 10000), where N denotes the number of cities and M denotes the number of one way roads. Each of the next M lines contains two integers u v (1 ≤ u, v ≤ N, u ≠ v) meaning that there is a road from u to v. Assume that there can be at most one road from a city u to v.
Output
For each case, print the case number and the minimum number of assassins needed to kill all targets.
Sample Input |
Output for Sample Input |
3
5 4 1 2 1 3 4 1 5 1
7 0
8 8 1 2 2 3 3 4 4 1 1 6 6 7 7 8 8 6 |
Case 1: 2 Case 2: 7 Case 3: 2 |
Note
Dataset is huge, use faster I/O methods.
Được gửi lên bởi: | Race with time |
Ngày: | 2012-11-06 |
Thời gian chạy: | 1s-2s |
Giới hạn mã nguồn: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Ngôn ngữ cho phép: | Tất cả ngoại trừ: ASM64 GOSU PERL6 PYPY RUST SED |
hide comments
2016-12-24 20:59:56
SCC + Path Cover |
|
2016-09-24 15:50:32
code: http://shink.in/wxiUV |
|
2015-03-05 15:27:11 Duc M. Pham
Edited Last edit: 2015-03-05 16:04:48 |
|
2014-11-26 15:33:20 livw
đề này của tàu khựa |
|
2012-11-07 13:06:31 Race with time
Em bị TLE |
|
2012-11-07 09:27:14 con_nha_ngheo
Ps xem hộ em xem em bị TLE hay là WA, em đc. 97.22 |