2013 Canadian Computing Competition, Stage 1

Problem S4: Who is taller?

You have a few minutes before your class starts, and you decide to compare the heights of your classmates. You dont have an accurate measuring device, so you just compare relative heights between two people: you stand two people back-to-back, and determine which one of the two is taller. Conveniently, none of your classmates are the same height, and you always compare correctly (i.e., you never make a mistake in your comparisons).

After you have done all of your comparisons, you would like to determine who the tallest person is between two particular classmates.

Input

The first line contains two integers N and M separated by one space. N, the number of people in the class, is an integer with 1 ≤ N ≤ 1000000. M, the number of comparisons that have already been done, is an integer with 1 ≤ M ≤ 10000000. Each of the next M lines contains two distinct integers x and y (1 ≤ xy ≤ N) separated by a space, indicating that person number x was determined to be taller than person number y. Finally, the last line contains two distinct integers p and q (1 ≤ pq ≤ N) separated by one space: your goal is to determine, if possible, whether person p is taller than person q. Note that it may be the case that neither p nor q occur in the input concerning measurements between classmates, and each measurement between any two particular people will be recorded exactly once.

Output

The output is one line, containing one of three possible strings:

  • yes (if p is taller than q),
  • no (if q is taller than p),
  • unknown (if there is not enough information to determine the relative heights of p and q).

Sample Input 1

10 3
8 4
3 8
4 2
3 2

Sample Output 1

yes

Sample Input 2

10 3
3 8
2 8
3 4
3 2

Sample Output 2

unknown

All Submissions
Best Solutions


Point Value: 10
Time Limit: 2.00s
Memory Limit: 64M
Added: May 19, 2013

Languages Allowed:
C++03, PAS, C, HASK, ASM, RUBY, PYTH2, JAVA, PHP, SCM, CAML, PERL, C#, C++11, PYTH3

Comments (Search)

I think the original memory limit was more than 64m - - 16m memory can't even fit 10000000 integers.

Try to use vector instead of array because the actual data size is only 1000000, and you want to pretend that you didn't look at the test data...