USACO Section5.4 Canada Tour (tour)

Problem Summary

Given a graph with vertices 1,2,…,N and M undirected edges, find the maximal length of a round trip.

The tour should have two parts. Let the first part be A[1]->A[2]->…->A[K], the second be B[1]->B[2]->…->B[P]. They should satisfy:

  1. A[1]=B[P]=1, A[K]=B[1]=N.
  2. The two parts have no common vertices except 1 and N, i.e. A[i]!=B[j], for any 1<i<K, 1<j<P.
  3. A[i]<A[j], for any 1<=i<j<=K
  4. B[i]>B[j], for any 1<=i<j<=P

Read More