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$)。題目保證對於每個 $i$,$a_i, b_i$ 同 $c_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.