The Largest City Nearby(NOIOPJENGLISH17)

这是一个图论问题,给定n个城市和它们之间的边长,需要找到一个城市id,使得从城市1出发能通过路径到达城市id,且路径长度不超过K。输入包括城市数量n和限制长度K,以及每对城市的边长。输出为满足条件的最大城市索引。样例输入和输出分别展示了如何处理这个问题。
摘要由CSDN通过智能技术生成

The Largest City Nearby

https://acs.jxnu.edu.cn/problem/NOIOPJENGLISH17

 1000ms  65536K

描述:

There are N cities, the length of edges between cities is given. Please find the city with the largest index id satisfying that there exisits a path between city 1 and city id and the length of this path is no more than K.

有n个城市,给出城市间边的长度,找出索引最长的城市,并使得城市1和它之间存在一条路径,且该路径的长度不超过K。

输入:

First line: two positive integers N (N <= 100) and K (K <= 10000).
Next N lines: the i-th line contains N non-negative integers (<= 100) indicating the length of edge between city i and other cities.

第一行:两个正整数表示n和k

接下来n行:第i行包含n个整数表示城市i和其他城市的距离

输出:

One integer id.

一个数表示id

样例输入:

4 6
0 4 5 7
4 0 9 3
5 9 0 1
7 3 1 0

样例输出:

4
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值