CodeChef is a non-commercial competitive programming community
Login
Username (New User? Signup) Password (Forgot Password?)
Signup
Login or
Signup with
Connect
Note
  • Publicize your achievements on your Facebook Wall.
  • Challenge your friends or ask them for help.

Site Navigation

  • PRACTICE
    • Easy
    • Medium
    • Hard
    • Challenge
    • Peer
  • COMPETE
    • All Contests
    • June Long 2012
    • May Cook-Off
    • May Long 2012
  • DISCUSS
    • Forums
    • Blog
    • Wiki
    • Facebook
    • Twitter
  • COMMUNITY
    • CodeChef Meetups
    • Campus Chapters
    • Host your Contest
    • User Groups
    • CodeChef TechTalks
    • All Educational Initiatives
  • HELP
    • Frequently Asked Questions
    • FAQ for problem setters
    • Problem Setting
    • Tutorials
    • Long Contest Ranks
    • Short Contest Ranks
    • Event Calendar
  • ABOUT
    • About CodeChef
    • Team CodeChef
    • Press Room
    • CodeChef Financials
    • CodeChef Sponsorships
    • CEO's Corner
    • Contact Us
    • About Directi
Home » Compete » Manthan 2010 » Travel Plan

Travel Plan

Problem code: CF03

  • All Submissions

All submissions for this problem are available.

XYZ is an International Airline Company. It has flights between different cities across the globe but does not have a direct flight for all the pairs of cities. Flights are such that, all the cities with an airport are reachable by other city either by a direct flight or through other cities. Total number of flights is of the order of number of airports.

For the past few years, their statistics are given below:

  • 2005 - 487 flights covering 319 different airports.
  • 2007 - 782 flights covering 549 different airports.
  • 2009 - 1197 flights covering 886 different airports.

They are planning to start a new flight between cities x and y, whose cost would be C units for the passengers. They need to calculate the percentage decrease in the total minimum cost for all pair of cities. So, let say total minimum cost to travel between all pairs of cities is initially C1 and after the new flight introduction becomes C2. You need to calculate (C1-C2)X100/C1.

Input

First line would give t (number of test cases).
Each test case starts with line containing n(number of cities) and f(number of flights) seperated by space.
All the cities are numbered as 0,1,2,...,n-1.
Next f lines will give, index of two cities(i and j) and the cost of flight(C).
Each case ends with a line containing x and y with its cost separated by space.
t<=10
n<=1000, f<=2000
C<=30000 units (is always an integer)

Output

For each test case output the percentage decrease rounded off to two decimal places on a separate line.

Example

Input:
2
3 2
0 1 3500
1 2 4000
0 2 2700
5 7
0 1 5500
2 3 8100
4 0 4300
1 2 2300
0 3 6000
4 2 3100
3 4 3700
1 3 2800
Output:
32.00
14.93

Author: manthan
Date Added: 26-03-2010
Time Limit: 3.5 sec
Source Limit: 50000 Bytes
Languages: C, CPP 4.0.0-8, CPP 4.3.2


  • Submit

Comments

  • Login or Register to post a comment.

is it to be assumed that x

TheCodebreakers @ 28 Mar 2010 06:42 PM

is it to be assumed that x and y will lie from 0 to n-1 only?

@TheCodebreakers: Yes, x and

manthan @ 28 Mar 2010 06:46 PM

@TheCodebreakers: Yes, x and y will lie between 0 and n-1.

Is n = 1, f = 0 0 0 123 x =

TheCodebreakers @ 28 Mar 2010 06:51 PM

Is n = 1, f = 0

0 0 123

x = 0, y = 0, C = 45

valid case?

Sorry f = 1 for previous

TheCodebreakers @ 28 Mar 2010 06:55 PM

Sorry f = 1 for previous query.

Invalid case. x and y can

manthan @ 28 Mar 2010 06:57 PM

Invalid case. x and y can never be same and so is i and j.

Also you can safely assume that f>0 and n>=2.

Is it possible that a flight

TheCodebreakers @ 28 Mar 2010 07:04 PM

Is it possible that a flight already exists between x and y? Also, are the flights two way or one way?

@Codebreakers: No, it is not

manthan @ 28 Mar 2010 07:12 PM

@Codebreakers: No, it is not possible that a flight already exists between x and y. All flights are two ways. The cost is same back and forth for a set of cities.

Current ranking is available

manthan @ 28 Mar 2010 08:08 PM

Current ranking is available at http://www.codechef.com/teams/list/MANTH10/

1. Are all the costs

dzhulgakov_team @ 28 Mar 2010 08:18 PM

1. Are all the costs nonnegative?

2. Answer is rounded using mathematical rules, isn't it? I.e., 10.234 = 10.23 and 10.235 = 10.24, right? And are there some tricky cases where answer is very close to rounding edge?

@dzhulgakov: 1. No. Costs

manthan @ 28 Mar 2010 08:24 PM

@dzhulgakov:

1. No. Costs are always positive.

2. Yes. You can use printf("%.2lfn",ans) for rounding off.

It said that "The contest

ForEver @ 28 Mar 2010 08:37 PM

It said that "The contest will last 6 hours and will have 8-10 problems."  on the codefest website:

http://itbhu.ac.in/codefest/event.php?eid=5

Why there are only 4 problems?

@All: The judge test cases

manthan @ 28 Mar 2010 08:47 PM

@All: The judge test cases have been modified. The rejudge is in process, but still do submit your codes again. Penalities, if any applied currrenlty for correct submissions will be removed

@ForEver - We thought it

manthan @ 28 Mar 2010 08:50 PM

@ForEver - We thought it would be difficult to solve all the problems in the given time constraints, so reduced the number of problems

But as you see many people

Anton_Lunyov_MANTH10 @ 28 Mar 2010 09:05 PM

But as you see many people have solved three problems.

So it is only one left on three hours.

Yes, and I'm a high-school

ForEver @ 28 Mar 2010 09:08 PM

Yes, and I'm a high-school student so I didn't learn Matrix.

I can't understand the only left problem. (>_<|||)

If there are some other problem , I will try some else.

@Anton_Lunyov & ForEver: We

manthan @ 28 Mar 2010 09:27 PM

@Anton_Lunyov & ForEver: We can not add any more problems now. There are lots of other teams still trying the problems.

When my successful solution

dzhulgakov_team @ 28 Mar 2010 09:58 PM

When my successful solution will appear in the scoreboard? It is listed in My Submissions and All Submissions as Accepted but in scoreboard I still have only 2 problems

My submissions shows the

countergambit1 @ 28 Mar 2010 10:12 PM

My submissions shows the problem as accepted, although the scoreboard is not updated. Can you update the scoreboard?

The ScoreBoard will be

manthan @ 28 Mar 2010 10:19 PM

The ScoreBoard will be updated tomorrow. The inconsistency is due to rejudging.

Final rankings will be considered after the error has been rectified.

SUCCESSFUL SUBMISSIONS FOR THIS PROBLEM:

Programming Competition Fetching successful submissions
Directi Go for Gold
CodeChef is a global programming communityCodeChef hosts online programming competitions
CodeChef is a non-commercial competitive programming community
  • About CodeChef
  • About Directi
  • CEO's Corner
  • C-Programming
  • Programming Languages
  • Contact Us
© 2009 Directi Group. All Rights Reserved. CodeChef uses SPOJ © by Sphere Research Labs
In order to report copyright violations of any kind, send in an email to copyright@codechef.com
CodeChef a product of Directi
The time now is:
CodeChef - A Platform for Aspiring Programmers

CodeChef was created as a platform to help programmers make it big in the world of algorithms, computer programming and programming contests. At CodeChef we work hard to revive the geek in you by hosting a programming contest at the start of the month and another smaller programming challenge in the middle of the month. We also aim to have training sessions and discussions related to algorithms, binary search, technicalities like array size and the likes. Apart from providing a platform for programming competitions, CodeChef also has various algorithm tutorials and forum discussions to help those who are new to the world of computer programming.

Practice Section - A Place to hone your 'Computer Programming Skills'

Try your hand at one of our many practice problems and submit your solution in a language of your choice. Our programming contest judge accepts solutions in over 35+ programming languages. Preparing for coding contests were never this much fun! Receive points, and move up through the CodeChef ranks. Use our practice section to better prepare yourself for the multiple programming challenges that take place through-out the month on CodeChef.

Compete - Monthly Programming Contests and Cook-offs

Here is where you can show off your computer programming skills. Take part in our 10 day long monthly coding contest and the shorter format Cook-off coding contest. Put yourself up for recognition and win great prizes. Our programming contests have prizes worth up to Rs.20,000 and $700lots more CodeChef goodies up for grabs.

Discuss

Are you new to computer programming? Do you need help with algorithms? Then be a part of CodeChef's Forums and interact with all our programmers - they love helping out other programmers and sharing their ideas. Have discussions around binary search, array size, branch-and-bound, Dijkstra's algorithm, Encryption algorithm and more by visiting the CodeChef Forums and Wiki section.

CodeChef Community

As part of our Educational initiative, we give institutes the opportunity to associate with CodeChef in the form of Campus Chapters. Hosting online programming competitions is not the only feature on CodeChef. You can also host a coding contest for your institute on CodeChef, organize an algorithm event and be a guest author on our blog.

Go For Gold

The Go for Gold Initiative was launched about a year after CodeChef was incepted, to help prepare Indian students for the ACM ICPC World Finals competition. In the run up to the ACM ICPC competition, the Go for Gold initiative uses CodeChef as a platform to train students for the ACM ICPC competition via multiple warm up contests. As an added incentive the Go for Gold initiative is also offering over Rs.8 lacs to the Indian team that beats the 29th position at the ACM ICPC world finals. Find out more about the Go for Gold and the ACM ICPC competition here.

Domain Name Registration, Web hosting, and Website Design provided by BigRock.com