Question: Problem S4: Daily Commute Problem Description Toronto has N subway stations, numbered from 1 to N. You start at station 1, and every day, you

Problem S4: Daily Commute Problem Description Toronto has N subway stations, numbered from 1 to N. You start at station 1, and every day, you need to reach station N to get to school There are W one-way walkways running amongst the stations, the th of which allows you to walk from station A to a different station B. (1 SAB, SN, A + B) in 1 minute, There may be multiple walkways connecting any given pair of stations, The subway line follows a certain route through the N stations, starting at station 1 and visiting each station once. Initially, this route consists of stations SS, ..., Sn, in that order. Si = 1, and S, Sy is a permutation of the integers 2,...,N. Only one subway train runs along this route per day, departing from station 1 at 6am in the morning and taking 1 minute to reach each subsequent station. This means that, m minutes after bam, the train will be at station Sm+1 (or at station Sy ifm > N - 1). Over a period of D days, however, the subway line's route will keep changing. At the start of the the day, the Xth station and Yth station (2 5 XY, SN, XY) in the route will be swapped. Note that, after each such change, the route will still begin at station 1 and will visit all N stations once each. Changes will carry over to subsequent days - the route will not automatically reset itself back to S,..., SN On each of these days, you'd like to determine how quickly you can get to school so you can begin learning things. On the the day, starting at 6am in the morning after the ith update to the subway line's route), you'll begin your daily trip to station N. Each minute, you may either ride the subway to its next stop (if you're currently at the same station as the train and it hasn't already completed its route), take a walkway from your current station to another one, or wait at your current station. Note that your trip begins at the same time as the train's route, meaning that you may choose to immediately ride it if you'd like to, and that you may choose to leave and then get back on the train during your trip. Input Specification The first line contains three space-separated integers, N. W and D. The next w lines each contain two space-separated integers, A and B (1 Sisw). The next line contains the N space-separated integers, S., Sn, which form the initial permutation of stations. The next D lines each contain two space-separated integers, X and Y. (I SISD). The following table shows how the available 15 marks are distributed. 2 marks 3N N - 1). Over a period of D days, however, the subway line's route will keep changing. At the start of the the day, the Xth station and Yth station (2 5 XY, SN, XY) in the route will be swapped. Note that, after each such change, the route will still begin at station 1 and will visit all N stations once each. Changes will carry over to subsequent days - the route will not automatically reset itself back to S,..., SN On each of these days, you'd like to determine how quickly you can get to school so you can begin learning things. On the the day, starting at 6am in the morning after the ith update to the subway line's route), you'll begin your daily trip to station N. Each minute, you may either ride the subway to its next stop (if you're currently at the same station as the train and it hasn't already completed its route), take a walkway from your current station to another one, or wait at your current station. Note that your trip begins at the same time as the train's route, meaning that you may choose to immediately ride it if you'd like to, and that you may choose to leave and then get back on the train during your trip. Input Specification The first line contains three space-separated integers, N. W and D. The next w lines each contain two space-separated integers, A and B (1 Sisw). The next line contains the N space-separated integers, S., Sn, which form the initial permutation of stations. The next D lines each contain two space-separated integers, X and Y. (I SISD). The following table shows how the available 15 marks are distributed. 2 marks 3N
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
