Imagine you are now a student in Tsing Hua University. There are many campuses locate in different places. Students need to take the shuttle bus to commute from one campus to another. Bad news is, not any two campuses have a shuttle bus. Students may need to transfer the bus. Also, if a student wants to change his major to another campus, he can exchange the credits in some proportion.
Now, you need to implement some operations to maintain this situation.
Operations:
Notice:
1. CreditExchange and CreditExchange2 will not show in same testcase. More specifically, the algorithm may be different depends on the range of exchange rate.
2. Credits are always integer. In every exchange, you should round down the credits to its floor. (Ex: 10.9 -> 10)
3. You are allowed to use stl except for those direct functions.
4. The number of campus is no more than 1000
A testcase will start with an input integer n (n<1000). It means the number of campus. The index of these campuses are 0 to n-1.
After first input, there are multiple operations. Some need to print the outcome and some don’t.
For operations “Add” and “Delete”, you don’t need to print anything.
For operations “Shortest” and “Map”, you need to print the minimum total moving time. If the output does not exist, print “Error”.
For operations “ImportantBus”, you need to print “Yes” if there exists one. Otherwise, print “No”.
For operations “CreditExchange” and “CreditExchange2”, you need to print the maximum credits you can get under the rules. If the output does not exist, print “0”.