A Better Battle Plan

Computer Science Level pending

During a battle, Sheldor the conqueror notices that his cities are in the form of a Directed Acyclic Graph, i.e, all the roads are one-way and there is no sequence of roads starting from a city that comes back into it.

Because the roads are one way, Sheldor wants to order them in a fashion which will let him know in which order he should he should progress his troops, i.e, he needs a permutation of the cities such that if there is a road from \(u\) to \(v\), \(v\) occurs after \(u\) in the permutation.

Four of his ministers, Alice, Bob, Charles and David attempt this problem and produce these answers:

Whose answer is correct?

Input File: Link

Input Format and Details:

  • There are 30 cities numbered from 1 to 30.
  • Each line of the file contains two integers u v in that order. This means that there is a directed edge from u to v.

Problem Loading...

Note Loading...

Set Loading...