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

24997번 - Well Off 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 128 MB108777.778%

문제

Thanks to his hard work, John, formerly Johnny, has become a member of the respectable Well Off Club. The club has $n$ members, numbered from 1ドル$ to $n$; the $i$-th club member has a fortune worth $x_i$. These can be arbitrary numbers, including negative ones. The reason for this is that the club membership is for life, i.e., neither impoverishment nor even bankruptcy results in an ousting.

The club members take pleasure in comparing their asset values, but they shun telling the number directly; it is their custom to engage in a conversation that lets them establish that their fortunes $x_i$ and $x_j$ satisfy one of the inequalities $x_i + x_j >0,ドル $x_i - x_j > 0,ドル $-x_i + x_j > 0,ドル or $-x_i - x_j > 0$.

Johnny (over-)heard many such inequalities today at the club, but he suspects that some of the members are lying. Help him determine if all the inequalities could possibly be true, i.e., if they can be simultaneously satisfied by some set of fortunes. Write a program that: reads the inequalities heard by Johnny, determines if they are satisfiable, and prints the answer to the standard output.

입력

In the first line of input there are two integers, $n$ and $m$ (1ドル \le n \le 100,000円,ドル 1ドル \le m \le 500,000円$), separated by a single space. These specify the number of club members and the number of inequalities relating their fortunes, respectively.

Each of the $m$ lines that follow describes one inequality, encoded by a + or - sign, an integer $i$ (1ドル \le i \le n$), another + or - sign, and an integer $j$ (1ドル \le j \le n$), separated by single spaces. These correspond to the inequality $\pm x_i \pm x_j > 0$ (with the signs as preceding $i$ and $j$ in the description). It might happen that $i=j$.

출력

The first and only line of the output should contain a single word: "TAK" if the system of inequalities is satisfiable, and "NIE" otherwise. % (Naturally, these are the Polish words for yes and no.)

제한

예제 입력 1

3 3
+ 1 - 2
- 3 + 1
+ 2 - 3

예제 출력 1

TAK

예제 입력 2

3 3
+ 1 - 2
+ 3 - 1
+ 2 - 3

예제 출력 2

NIE

노트

In Sample 1, system of inequalities is satisfiable, e.g. by $x_1 = 3,ドル $x_2 = 2,ドル $x_3 = 1$.

In Sample 2, system of inequalities is not satisfiable.

출처

ICPC > Regionals > Europe > Central European Regional Contest > Poland Collegiate Programming Contest > AMPPZ 2015 B번

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

출처

대학교 대회

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

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