Universal Cup Judging System

Universal Cup

시간 제한: 3.0 s 메모리 제한: 1024 MB 총점: 100 해킹 가능 ✓
통계

Beschreibung

Herr Nežmah hat einen eigenartigen Geschmack bei Tripeln. Er mag $m$ ungeordnete Tripel paarweise verschiedener Zahlen $(a_i, b_i, c_i)$.

Ein Zyklus der Länge $k$ ist eine Folge von (nicht unbedingt verschiedenen) Zahlen $v_1, \dots, v_k$, bei der jeweils drei aufeinanderfolgende Zahlen ein Tripel bilden, das Nežmah mag, ebenso wie $(v_{k-1}, v_k, v_1)$ und $(v_k, v_1, v_2)$.

Ein Zyklus heißt krumm, wenn seine Länge nicht durch $3$ teilbar ist. Prüfe, ob ein krummer Zyklus existiert.

Eingabe

Die erste Zeile enthält eine ganze Zahl $t$ ($1 \le t \le 2 \cdot 10^4$), die Anzahl der Testfälle.

Die erste Zeile jedes Testfalls enthält eine ganze Zahl $m$ ($1 \le m \le 2 \cdot 10^5$), die Anzahl der Tripel.

Die folgenden $m$ Zeilen enthalten die ganzen Zahlen $a_i, b_i$ und $c_i$ ($1 \le a_i, b_i, c_i \le 2 \cdot 10^5$). Es wird garantiert, dass $a_i, b_i$ und $c_i$ für jedes $i$ paarweise verschieden sind und dass alle ungeordneten Tripel verschieden sind.

Es wird garantiert, dass die Summe von $m$ über alle Testfälle $2 \cdot 10^5$ nicht überschreitet.

Ausgabe

Gib für jeden Testfall yes aus, falls ein krummer Zyklus existiert; andernfalls gib no aus.

Beispiele

Beispiel 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

Hinweis

Im zweiten Testfall bildet $(2, 3, 5, 2, 6, 3, 2, 7, 3, 6)$ einen krummen Zyklus (obwohl es auch kleinere gibt).

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.