시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
5 초 512 MB 201 61 38 28.358%

문제

일호는 매년 열리는 국제 체스대회의 심사 위원이다. 

국제 체스대회의 경기는 오로지 심판인 일호만 관전하며 일호가 경기 결과를 체스협회 회장인 진서에게  통보하면 진서가 결과들을 종합하여 순위를 발표하게 된다.

이러한 룰 때문에 일호가 경기 결과를 진서에게 실수로 잘못 통보한다면 아무도 경기 결과가 바뀐지 알 수 없다.

체스 경기는 우연이 아닌 기술의 게임이기 때문에 A플레이어의 기술 수준이 B플레이어의 기술 수준보다 더 높으면 A플레이어는 B플레이어를 항상 이길것이다. 이때 두플레이어의 기술 수준이 같다면 경기를 비길 수도 있다.

우리는 일호가 경기 과정을 진서에게 전달 하는 과정에서 실수가 발생했을 수도 있으므로 선수들의 경기 결과가 일관성이 있는지 확인을 해야한다.

예를 들어 0 > 1 , 1 = 2 , 0 = 2 의 결과가 나왔다면 0번 선수의 기술 수준은 1번 선수의 기술 수준보다 높을 것이다. 

하지만 1번 선수의 기술 수준과 2번 선수의 기술 수준이 같고, 0번 선수의 기술 수준과 2번 선수의 기술 수준이 같다면 0번선수의 기술 수준과 1번 선수의 기술 수준이 같다는 결론을 도출할 수 있으므로, 0번 선수와 1번 선수의 기술 점수에 대한 모순이 생기게 되므로 일호가 진서에게 경기 결과를 잘못 전달한 것이다.

우리는 일관성을 판단하여 경기 결과가 잘 전달 됐는지 확인하는 프로그램을 만들면 된다.

입력

첫째 줄에 플레이어 수 N(2  ≤ N  ≤ 50 000) 와   경기 결과의 수 M(1  ≤ M  ≤ 250 000) 이 주어진다.

이어서 M개의 줄에 경기 결과 K S L이 주어진다.

K와 L은 경기를 치룬 선수이고 S는 '=' 혹은 '>' 로 표현된다.

K > L 이면 해당 경기에서 K가 L을 이긴것이다.  

두 플레이어 간에는 최대 하나의 경기만 있으며, 각 플레이어는 적어도 하나의 경기에 참여한다. 

출력

주어진 경기 결과들이 일관성이 있다면 "consistent"를 출력하고 아니라면 "incon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IGEgcGxheWVyICgwICZsZTsgSywgTCAmbHQ7IE4pLiBJZiZuYnNwO3RoZSBzeW1ib2wgaXMgJmxzcXVvOz0mcnNxdW87LCB0aGVuIHRoZSBnYW1lIGJldHdlZW4gSyBhbmQgTCB3YXMgYSBkcmF3LiBJZiB0aGUgc3ltYm9sIGlzICZsc3F1bzsmZ3Q7JnJzcXVvOywgdGhlbiBLJm5ic3A7YmVhdCBMIGluIGEgbWF0Y2guPFwvcD5cclxuXHJcbjxwPllvdSBtYXkgYXNzdW1lIHRoYXQgdGhlcmUgaXMgYXQgbW9zdCBvbmUgcmVwb3J0ZWQgbWF0Y2ggYmV0d2VlbiBhbnkgZ2l2ZW4gcGFpciBvZiBwbGF5ZXJzLiZuYnNwO0Fsc28sIGVhY2ggcGxheWVyIHRha2VzIHBhcnQgaW4gYXQgbGVhc3Qgb25lIHJlcG9ydGVkIG1hdGNoLjxcL3A+XHJcbiIsIm91dHB1dCI6IjxwPk91dHB1dCBhIHNpbmdsZSBsaW5lIGNvbnRhaW5pbmcgYSBzaW5nbGUgd29yZDogJmxkcXVvO2NvbnNpc3RlbnQmcmRxdW87IGlmIHRoZSBsaXN0IG9mIHJlY29yZGVkIG1hdGNoZXMmbmJzcDtpcyBjb25zaXN0ZW50LCBhbmQgJmxkcXVvO2luY29uc2lzdGVudCZyZHF1bzsgaWYgaXQgaXMgbm90LjxcL3A+XHJcbiIsImhpbnQiOiIiLCJvcmlnaW5hbCI6IjEiLCJwcm9ibGVtX2xhbmdfY29kZSI6Ilx1YzYwMVx1YzViNCJ9XQ==

출처

ACM-ICPC > Regionals > Europe > Northwestern European Regional Contest > Benelux Algorithm Programming Contest > BAPC 2016 Preliminaries B번