Woburn Challenge 2018-19 Finals Round - Senior Division
With principal photography on the cows' and monkeys' project having concluded, it won't be long now before post-production wraps up and the film can be shown to the public! In preparation for the initial run of screenings, the Head Monkey and Bo Vine are taking it upon themselves to personally put up movie posters at movie theatres all across the land of Ontario.
There are
There are also
The Head Monkey will begin in city
Between the two of them, the Head Monkey and Bo Vine would like to put
up a poster at every movie theatre in Ontario. In other words, for each
city
Subtasks
In test cases worth
In test cases worth another
Input Specification
The first line of input consists of three space-separated integers,
The next line consists of
Output Specification
Output a single integer, the minimum number of hours required for the Head Monkey and Bo Vine to visit all of the theatres and each return to their original city.
Sample Input 1
5 2 4
00101
1 2
2 3
3 4
4 5
Sample Output 1
2
Sample Input 2
8 1 6
00110011
1 2
2 3
2 4
4 5
1 6
6 7
7 8
Sample Output 2
6
Sample Input 3
5 1 2
00101
5 4
3 1
1 2
4 1
Sample Output 3
4
Sample Explanation
In the first case, one possible optimal pair of routes is as follows:
- Head Monkey:
- Bo Vine:
In the second case, one possible optimal pair of routes is as follows:
- Head Monkey:
- Bo Vine:
In the third case, one possible optimal pair of routes is as follows:
- Head Monkey:
- Bo Vine:
Comments