编程介的小学生 2019-04-18 16:39 采纳率: 20.5%
浏览 123

相关性的数据结构的组织的算法,利用C语言的程序的设计的思路怎么做?

Problem Description
When Wiskey return home, many relatives he need to visit, and he will buy some gifts before he visit his relatives. There is a map which has N places; Wiskey's house is labeled 0. He has T tasks which from u to v, it mean Wiskey could go to v when he bought a gift at u before.
Wiskey always start at 0, and must end with 0.
Tell him how many minimum total places he went when he finished all tasks.

Input
First line will contain one integer mean how many cases will follow by; the number of cases wills less than 20.
In each case will contain three integers N means the number of places, M roads and T tasks. (1 <= N <= 20, 0 <= M <= 100, 0 <= T <= 5).
First, M roads will be follow; the road is bi-connected.
Second, T tasks will be follow; you are remember the u must went earlier than v, then what makes the task will be finished.

Output
Print the minimum total number of places he went.
If Wiskey can't finish all tasks, please print -1.

Sample Input
1
7 11 5
0 1
0 2
1 2
1 4
0 3
3 4
4 6
2 6
6 5
3 5
4 5
1 2
1 3
2 0
1 4
5 3

Sample Output
7

  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 maple软件,用solve求反函数出现rootof,怎么办?
    • ¥50 汇编语言除法溢出问题
    • ¥65 C++实现删除N个数据列表共有的元素
    • ¥15 Visual Studio问题
    • ¥15 state显示变量是字符串形式,但是仍然红色,无法引用,并显示类型不匹配
    • ¥20 求一个html代码,有偿
    • ¥100 关于使用MATLAB中copularnd函数的问题
    • ¥20 在虚拟机的pycharm上
    • ¥15 jupyterthemes 设置完毕后没有效果
    • ¥15 matlab图像高斯低通滤波