시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
5 초 512 MB 169 53 35 28.000%

문제

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

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

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

체스 경기는 우연이 아닌 기술의 게임이기 때문에 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"를 출력하고 아니라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hlIGludGVnZXJzIEsgYW5kIEwgZWFjaCB1bmlxdWVseSBpZGVudGlmeSBhIHBsYXllciAoMCAmbGU7IEssIEwgJmx0OyBOKS4gSWYmbmJzcDt0aGUgc3ltYm9sIGlzICZsc3F1bzs9JnJzcXVvOywgdGhlbiB0aGUgZ2FtZSBiZXR3ZWVuIEsgYW5kIEwgd2FzIGEgZHJhdy4gSWYgdGhlIHN5bWJvbCBpcyAmbHNxdW87Jmd0OyZyc3F1bzssIHRoZW4gSyZuYnNwO2JlYXQgTCBpbiBhIG1hdGNoLjxcL3A+XHJcblxyXG48cD5Zb3UgbWF5IGFzc3VtZSB0aGF0IHRoZXJlIGlzIGF0IG1vc3Qgb25lIHJlcG9ydGVkIG1hdGNoIGJldHdlZW4gYW55IGdpdmVuIHBhaXIgb2YgcGxheWVycy4mbmJzcDtBbHNvLCBlYWNoIHBsYXllciB0YWtlcyBwYXJ0IGluIGF0IGxlYXN0IG9uZSByZXBvcnRlZCBtYXRjaC48XC9wPlxyXG4iLCJvdXRwdXQiOiI8cD5PdXRwdXQgYSBzaW5nbGUgbGluZSBjb250YWluaW5nIGEgc2luZ2xlIHdvcmQ6ICZsZHF1bztjb25zaXN0ZW50JnJkcXVvOyBpZiB0aGUgbGlzdCBvZiByZWNvcmRlZCBtYXRjaGVzJm5ic3A7aXMgY29uc2lzdGVudCwgYW5kICZsZHF1bztpbmNvbnNpc3RlbnQmcmRxdW87IGlmIGl0IGlzIG5vdC48XC9wPlxyXG4iLCJoaW50IjoiIiwib3JpZ2luYWwiOiIxIiwicHJvYmxlbV9sYW5nX2NvZGUiOiJcdWM2MDFcdWM1YjQifV0=

출처

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