Universal Cup Judging System

Universal Cup

حد الوقت: 3.0 s حد الذاكرة: 1024 MB مجموع النقاط: 100 قابلة للهجوم ✓
الإحصائيات

คำอธิบายโจทย์

คุณ Nežmah มีรสนิยมที่แปลกประหลาดเกี่ยวกับสิ่งอันดับสาม เขาชอบสิ่งอันดับสามแบบไม่คิดลำดับจำนวน $m$ ชุด ที่ประกอบด้วยตัวเลขที่แตกต่างกันเป็นคู่ ๆ $(a_i, b_i, c_i)$

วัฏจักร ที่มีความยาว $k$ คือลำดับของตัวเลข (ที่ไม่จำเป็นต้องแตกต่างกัน) $v_1, \dots, v_k$ ซึ่งทุก ๆ สามตัวเลขที่อยู่ติดกันจะประกอบกันเป็นสิ่งอันดับสามที่ Nežmah ชอบ รวมถึง $(v_{k-1}, v_k, v_1)$ และ $(v_k, v_1, v_2)$ ด้วย

วัฏจักรจะเรียกว่า บิดเบี้ยว หากความยาวของมันหารด้วย $3$ ไม่ลงตัว จงตรวจสอบว่ามีวัฏจักรบิดเบี้ยวอยู่หรือไม่

ข้อมูลนำเข้า

บรรทัดแรกประกอบด้วยจำนวนเต็ม $t$ ($1 \le t \le 2 \cdot 10^4$) แทนจำนวนชุดทดสอบ

บรรทัดแรกของแต่ละชุดทดสอบประกอบด้วยจำนวนเต็ม $m$ ($1 \le m \le 2 \cdot 10^5$) แทนจำนวนสิ่งอันดับสาม

อีก $m$ บรรทัดถัดมาประกอบด้วยจำนวนเต็ม $a_i, b_i$ และ $c_i$ ($1 \le a_i, b_i, c_i \le 2 \cdot 10^5$) รับประกันว่า $a_i, b_i$ และ $c_i$ แตกต่างกันเป็นคู่ ๆ สำหรับแต่ละ $i$ และสิ่งอันดับสามแบบไม่คิดลำดับทั้งหมดแตกต่างกัน

รับประกันว่าผลรวมของ $m$ ในทุกชุดทดสอบไม่เกิน $2 \cdot 10^5$

ข้อมูลส่งออก

สำหรับแต่ละชุดทดสอบ ให้แสดงผล yes หากมีวัฏจักรบิดเบี้ยว มิฉะนั้นให้แสดงผล no

ตัวอย่าง

ตัวอย่าง 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

หมายเหตุ

ในชุดทดสอบที่สอง $(2, 3, 5, 2, 6, 3, 2, 7, 3, 6)$ ก่อให้เกิดวัฏจักรบิดเบี้ยว (แม้ว่าจะมีวัฏจักรที่เล็กกว่านี้ด้วยก็ตาม)

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.