Universal Cup Judging System

Universal Cup

時間限制: 3.0 s 記憶體限制: 1024 MB 總分: 100 可 Hack ✓
统计

الوصف

لدى السيد 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.