编程介的小学生 2017-04-04 07:26 采纳率: 20.5%
浏览 826
已采纳

Calculate Roads

Little Vitta needs to go from home to school every day. On her way to school, there are n crossing and m roads in total. Because of lazy, she often gets up late in the morning. In order to get to school on time, she wishes that she can always go to school in the shortest path.(Assume that the time cost on every road is 1. And all roads are bidirectional. That is to say, if she can go from A to B, she always can go from B to A). But on some specific crossings, there are some terrible insects which makes Vitta scared. She expects the crossings which has insects don't exceed k. She wants know the number of all possible paths, can you help her?

Input

We assume Vitta's home is node 1, and the school is node n.

For each case, there are 3 integers in first line, m n k(m <= 1000000, n <= 5000, k <= 50), as the problem statement says.

In the following n lines, every line contains 2 integer x and y. y equals 1 means node x has terrible insects else if y equals 0 means there is no insect.

In the following m lines, every line contains 2 integer p and q, which means node p and node q is linked.

Output

For each case, output contains only 1 line.

If the path satisfies the requirement exists, you only need to output the numbers of paths. If not, you should output "Impossible!"

Sample Input

11 8 1
1 0
2 1
3 0
4 0
5 1
6 1
7 0
8 0
1 2
1 3
1 4
2 5
2 6
3 5
3 7
4 6
5 8
6 8
7 8

Sample Output

3

Hint To Sample

3 possible paths are 1-3-5-8 1-4-6-8 1-3-7-8

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-04-16 15:28
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥50 易语言把MYSQL数据库中的数据添加至组合框
  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况