Today in Russia it's not just the 20th of september, it's Recruiter's Day. In Azerbaijan – Oil Industry Worker's Day, and in Belarus – Customs Officer's Day. But for us it's another good day to arrange the round. Welcome to Codeforces Beta Round #29 (Div. 2, Codeforces format)!

Helped with preparation of the round: Mike Mirzayanov, Dmitry Matov, Gerald Agapov and Nickolay Kuznetsov, thank them for that.

Happy Recruiter's Day,

Artem Rakhov

3

2 6

5 3

8 -6

interesting.. seems can't find the submission "You don't have access to view this submission"

3Q~

Now I see, that I just used too little constant in array declaration. What a silly fail. :-)

it's obvious that if the shortest path in the graph has even numbers of nodes, than that's a solution.. but what to do if that is not the case?

You can represent each state as (x1, y1), where x1 and y1 are the location of the two guys. Then you can transition from (x1, y1) to (x2, y2) at a cost of 1 if there exists edges (x1, x2) and (y1, y2). Ensure that x2 != y2. Thus, you begin with (1, n), and terminate at (n, 1). Since each transition is equally weighted, a normal queue is sufficient.

My solution was fairly sketchy since I got TLE using some C++ STL, but it passed with time 800ms when I manually implemented them. I'm wondering if there are more efficient solutions.

Sorry about the confusion; I meant BFS instead of Dijkstra. Basically a Dijkstra without checking to see if the new distance is lower.

## What's test 19 in problem B?