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.