Automated Program Analyzer
면접 대비시간 제한2초메모리 제한1024 MB
여러 변수에 대한 등식과 부등식 제약을 동시에 만족시킬 수 있는지 판정한다.
문제
Let be variables. constraints of form or 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 , then those constraints cannot be satisfied simultaneously.
입력
The first line of the input is an integer representing the number of instances to solve. The instances are independent. For each instance, the first line is an integer representing the number of constraints to be satisfied. In the following lines, each line has three integers representing an equality/inequality constraint. If , the constraint shall be . If , the constraint shall be .
출력
The output has lines. The -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.