Universal Cup Judging System

Universal Cup

Time Limit: 3.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

Mô tả bài toán

Ông Nežmah có một sở thích kỳ lạ về các bộ ba. Ông thích $m$ bộ ba không thứ tự gồm các số đôi một khác nhau $(a_i, b_i, c_i)$.

Một chu trình độ dài $k$ là một dãy gồm các số (không nhất thiết phân biệt) $v_1, \dots, v_k$ sao cho mỗi ba số liên tiếp đều tạo thành một bộ ba mà Nežmah thích, cũng như $(v_{k-1}, v_k, v_1)$ và $(v_k, v_1, v_2)$.

Một chu trình được gọi là lệch nếu độ dài của nó không chia hết cho $3$. Hãy kiểm tra xem có tồn tại một chu trình lệch hay không.

Dữ liệu vào

Dòng đầu tiên chứa một số nguyên $t$ ($1 \le t \le 2 \cdot 10^4$), số lượng bộ test.

Dòng đầu tiên của mỗi bộ test chứa một số nguyên $m$ ($1 \le m \le 2 \cdot 10^5$), số lượng bộ ba.

$m$ dòng tiếp theo chứa các số nguyên $a_i, b_i$, và $c_i$ ($1 \le a_i, b_i, c_i \le 2 \cdot 10^5$). Đảm bảo rằng $a_i, b_i$, và $c_i$ đôi một khác nhau với mỗi $i$, và tất cả các bộ ba không thứ tự đều phân biệt.

Đảm bảo rằng tổng của $m$ trên tất cả các bộ test không vượt quá $2 \cdot 10^5$.

Dữ liệu ra

Với mỗi bộ test, in ra yes nếu tồn tại một chu trình lệch; ngược lại, in ra no.

Ví dụ

Ví dụ 1

3
4
1 2 3
2 3 4
3 4 1
4 1 2
8
3 2 5
6 3 7
7 3 2
1 5 6
5 2 6
7 4 6
3 2 6
3 2 1
7
7 4 6
2 3 7
7 2 4
5 4 6
3 6 7
5 3 6
1 4 6
yes
yes
no

Ghi chú

Trong bộ test thứ hai, $(2, 3, 5, 2, 6, 3, 2, 7, 3, 6)$ tạo thành một chu trình lệch (mặc dù cũng có những chu trình nhỏ hơn).

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.