Logo
(追記) (追記ここまで)

6835번 - King & Weber 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
1 초 128 MB633100.000%

문제

It is easy to get lost in Kitchener-Waterloo. Many streets that are mostly parallel actually intersect, sometimes multiple times. The best-known example is King and Weber Streets. Other examples include Westmount and Fischer-Hallman, University and Erb, and Queen and Highland.

Navigation is easier in cities that respect the “Manhattan Assumption”: all streets are straight lines in a Euclidean plane, and any two streets are either parallel or perpendicular to each other. Visitors to Manhattan are cautioned that even Manhattan itself does not fully satisfy this assumption.

The input to your program will be a sequence of observations followed by a sequence of queries for a particular city. An observation asserts either that two streets are parallel, or that they intersect. A query asks whether two streets are parallel, or whether they intersect, provided the city satisfies the Manhattan Assumption.

입력

The first line of input contains two integers m and n (1 ≤ m, n ≤ 100000). Each of the following m lines contains an observation. Each observation consists of three words separated by spaces: the two street names, and either the word parallel or the word intersect. Each street name is a sequence of no more than 100 uppercase or lowercase letters. The observations are followed by n queries, each on a separate line. A query consists of two street names separated by a space.

출력

If it is impossible for the city to conform to both the Manhattan Assumption and the specified observations, output a single line containing the word Waterloo. Otherwise, output n lines containing the answers to the n queries. Each answer should be one of the following three words: parallel, intersect, unknown. If the two streets queried are parallel in every city satisfying the given observations and the Manhattan Assumption, the output should be parallel. If they are perpendicular in every such city, the output should be intersect. If they are parallel in some such city and perpendicular in another such city, the output should be unknown.

제한

예제 입력 1

3 3
fourthstreet fifthstreet parallel
fifthstreet sixthstreet parallel
fourthavenue fifthstreet intersect
sixthstreet fourthstreet
sixthstreet fourthavenue
sixthstreet King

예제 출력 1

parallel
intersect
unknown

예제 입력 2

2 1
King Weber parallel
King Weber intersect
King Weber

예제 출력 2

Waterloo

힌트

출처

Olympiad > Canadian Computing Competition & Olympiad > 2008 > CCO 2008 2번

(追記) (追記ここまで)

출처

대학교 대회

  • 사업자 등록 번호: 541-88-00682
  • 대표자명: 최백준
  • 주소: 서울시 서초구 서초대로74길 29 서초파라곤 412호
  • 전화번호: 02-521-0487 (이메일로 연락 주세요)
  • 이메일: contacts@startlink.io
  • 통신판매신고번호: 제 2017-서울서초-2193 호

AltStyle によって変換されたページ (->オリジナル) /