编程介的小学生 2020-01-18 23:51 采纳率: 20.5%
浏览 65

Visit relatives 便利的问题

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条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥20 iqoo11 如何下载安装工程模式
    • ¥15 flask项目,怎么使用AJAX传数据库数据到echarts图表的data里,实现异步加载数据。
    • ¥15 本题的答案是不是有问题
    • ¥15 关于#r语言#的问题:(svydesign)为什么在一个大的数据集中抽取了一个小数据集
    • ¥15 C++使用Gunplot
    • ¥15 这个电路是如何实现路灯控制器的,原理是什么,怎么求解灯亮起后熄灭的时间如图?
    • ¥15 matlab数字图像处理频率域滤波
    • ¥15 在abaqus做了二维正交切削模型,给刀具添加了超声振动条件后输出切削力为什么比普通切削增大这么多
    • ¥15 ELGamal和paillier计算效率谁快?
    • ¥15 蓝桥杯单片机第十三届第一场,整点继电器吸合,5s后断开出现了问题