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

25077번 - Automated Program Analyzer 다국어

시간 제한메모리 제한제출정답맞힌 사람정답 비율
2 초 1024 MB130272422.018%

문제

Let $x_1, x_2, x_3, \dots$ be variables. $n$ constraints of form $x_i = x_j$ or $x_i \ne x_j$ are given. The task asks for whether it is possible to assign values to the variables so that all constraints can be satisfied. For example, if the constraints are $x_1 = x_2, x_2 = x_3, x_3 = x_4, x_1 \ne x_4,ドル then those constraints cannot be satisfied simultaneously.

입력

The first line of the input is an integer $t$ representing the number of instances to solve. The instances are independent. For each instance, the first line is an integer $n$ representing the number of constraints to be satisfied. In the following $n$ lines, each line has three integers $i,j,e$ representing an equality/inequality constraint. If $e = 1,ドル the constraint shall be $x_i = x_j$. If $e = 0,ドル the constraint shall be $x_i \ne x_j$.

출력

The output has $t$ lines. The $k$-th line of the output is a string YES or NO. Output YES if the constraints in that instance can be satisfied and NO otherwise.

제한

  • 1ドル \le n \le 100,000円$
  • 1ドル \le i, j \le 1,000円,000円,000円$
  • 1ドル \le t \le 10$
  • $e \in \{0,1\}$

예제 입력 1

2
2
1 2 1
1 2 0
2
1 2 1
2 1 1

예제 출력 1

NO
YES

예제 입력 2

2
3
1 2 1
2 3 1
3 1 1
4
1 2 1
2 3 1
3 4 1
1 4 0

예제 출력 2

YES
NO

힌트

출처

Olympiad > National Olympiad in Informatics (China) > NOI 2015 1번

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

출처

대학교 대회

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

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