若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。


  • 运维

  • 前端

  • 编程

  • 随笔

  • hust-oj

2365: UFO

发表于 2017-10-06   |   分类于 HUSTOJ   |   阅读次数 1,397

题目描述

UFO likes traveling by bike very much. He intends to travel this summer. Due to lack of money, he must bring things and exchange them with others. When he arrives in a city, he sells everything he has and buys new things. Then he travels to another city, sells his items and buys new ones. In this problem you will have to find the total amount of money UFO will gain on the optimal tour. On a tour he can go to some city more than once, and he must finish his tour in some cities. Also there is a starting city for his tour and the number of inter-city travels he wants to do in his tour.

输入

The input file contains several test cases. The first line is N: the number of test cases. Then follows N cases. The description of each case is given below: Each case starts with four integers C (2 <= C <= 100), the number of cities, and the cities are numbered from 1 to C, S (1 <= S <= C), the identifier of the starting city, E (1 <= E <= C-1), the number of cities his tour can end at, and T (1 <= T <= 1000), the number of inter-city travels he wants to do. Follow C lines with C non-negative integers which are no more than 1000. The jth integer of the ith line will describe the profit he earns when he goes from city i to city j by selling things. As he does not want to make a trip to a city he is already, the ith integer of the ith line will always be 0. Note that going from city i to city j can have a different profit than going from city j to city i. After there will be a line with E integers, the identifier of the cities he can end his tour.

输出

For each input case produce one line of output, the total profit he can earn in the corresponding tour.

样例输入

1
3 1 2 2
0 3 5
5 0 1
9 2 0
2 3

样例输出

7

参考代码

暂无

解析

暂无

hustoj

发表评论 取消回复

邮箱地址不会被公开。 必填项已用*标注

*
*


hoxis wechat
著作权归作者所有
站点更新说明
  • 文章目录
  • 站点概览
若是凉夜已成梦

若是凉夜已成梦

青春里 总有些事情要努力去做 总有些梦想要拼命去追。

1904 日志
6 分类
12 标签
RSS
weibo github twitter facebook

友情链接

Skip 原站点 Dreams孤独患者
© 2017 若是凉夜已成梦
Powered by WordPress | 已运行
Theme By NexT.Mist