All Submissions


Problem Description :

Its that dreaded time of the year again, when BIT-ians have to spend hours which even translate into days for a few unfortunate souls, waiting in queues to get their 'No-Dues' application signed, just so that they can appear for the extremely pleasurable experience called the End Semester Exams. Much like a treasure hunt, students run from one room to the other, trying to get the different fields in the forms signed. There are a few offices in which more than one field is validated and the clerks at each office are kind enough to redirect you to your next destination. To make sure that the students have multiple ways of suffering to choose from, BIT now has more than one room for a few of the offices. Keep in mind that each queue moves at different speeds. Ultimately, once every field has been verified and signed, you have to bring the form to the Dean, Mr. Almighty for his signature.
To simplify the matter, you and your friends prepared a map of the offices. Now provided the rate at which the queue in front of each of the offices(/rooms) moves (Rate = The number of people per day), your task is to calculate the number of students who will actually make it out of Mr. Almighty's Office (alive :P).

Input Specification :
  • There are multiple input sets, each of whose first line consists of two inputs n and e where n = the number of rooms (assuming that the students are initially in Room #1) and p = the total number of paths between the Rooms.
  • Next we have 'p' input lines where we specify two room numbers and the rate at which the queue moves between them.
  • On the next line we specify the room number of the Dean's office.
  • Assume that there are infinite number of students and that all of them are initially in Room #1.
  • Read till End Of File.

Output Specifications :

For each test case, print out a single line the number of students who get out of the Dean's office in one day.

Constraints :
  • 5 <= Number of Rooms <= 100
  • 1 <= Room Numbers <= 100
  • 1 <= Rate <= 1000


Sample Input :


7 9
1 2 100
1 3 150
2 4 75
2 5 80
3 4 75
3 5 90
4 7 65
5 6 70
6 7 85
7


Sample Output :


135


Question Setter : Vishnu Mohandas

Languages: C,C++,Java

Time Limit: 1 Second(s)
Score: 100 Point(s)
Input File Limit: 50000 Bytes

Submit

Login to post clarification.

No Clarifications.

Contest

Mode Judge

Passive

Online

Overall Rankings

RankNameScore
1xyz0
2Ams0
3TIP0
4team420
5xyzz0
6asdasdasd0
7abcd0
8khankhan0
9Gabriel0
10gigel0