4. 社交友谊(我喜欢做家教 I Like Being a Tutor)

原文链接:http://talk.oralpractice.com/article_14538.html

- I like being a tutor.

- Are you well-paid?

- Earning money is not the most important.

It gives me a sense of achievement.

我喜欢做家教。

薪水很高吗?

赚钱并不是最重要的。做家教给我一种成就感。

展开阅读全文

Being a Hero

08-30

TasknnYou are the hero who saved your country. As promised, the king will give you some cities of the country, and you can choose which ones to own!nnBut don't get too excited. The cities you take should NOT be reachable from the capital -- the king does not want to accidentally enter your area. In order to satisfy this condition, you have to destroy some roads. What's worse, you have to pay for that -- each road is associated with some positive cost. That is, your final income is the total value of the cities you take, minus the total cost of destroyed roads.nnNote that each road is a unidirectional, i.e only one direction is available. Some cities are reserved for the king, so you cannot take any of them even if they're unreachable from the capital. The capital city is always the city number 1.nnInputnnThe first line contains a single integer T (T <= 10), the number of test cases. Each case begins with three integers n, m, f (1 <= f < n <= 1000, 1 <= m < 100000), the number of cities, number of roads, and number of cities that you can take. Cities are numbered 1 to n. Each of the following m lines contains three integers u, v, w, denoting a road from city u to city v, with cost w. Each of the following f lines contains two integers u and w, denoting an available city u, with value w.nOutputnnFor each test case, print the case number and the best final income in the first line. In the second line, print e, the number of roads you should destroy, followed by e integers, the IDs of the destroyed roads. Roads are numbered 1 to m in the same order they appear in the input. If there are more than one solution, any one will do.nSample Inputnn2n4 4 2n1 2 2n1 3 3n3 2 4n2 4 1n2 3n4 4n4 4 2n1 2 2n1 3 3n3 2 1n2 4 1n2 3n4 4nSample OutputnnCase 1: 3n1 4nCase 2: 4n2 1 3 问答

没有更多推荐了,返回首页