#P4610. [COI 2012] KAMPANJA

    ID: 3553 远端评测题 1500ms 250MiB 尝试: 0 已通过: 0 难度: 8 上传者: 标签>搜索2012最短路概率论,统计COCI

[COI 2012] KAMPANJA

Description

There are NN cities and MM directed edges, satisfying 2N100,2M2002 \le N \le 100, 2 \le M \le 200.

We need to find, among all routes that start from city 11, pass through city 22 on the way, and finally return to city 11, the minimum number of cities that need to be visited. The testdata guarantees that a solution exists.

Input Format

The first line contains two integers N,MN, M. NN is the number of cities, and MM is the number of directed edges.

The next MM lines each contain two integers A,BA, B, indicating a directed edge from AA to BB.

Output Format

Output the minimum number of cities that need to be monitored.

6 7
1 3
3 4
4 5
5 1
4 2
2 6
6 3
6

Hint

For 100%100\% of the testdata, 2N100,2M2002 \le N \le 100, 2 \le M \le 200 holds.

The testdata for this problem is strengthened by Imagine.

Translated by ChatGPT 5