結果
| 問題 |
No.2780 The Bottle Imp
|
| コンテスト | |
| ユーザー |
寝癖
|
| 提出日時 | 2024-06-07 22:16:43 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 642 bytes |
| コンパイル時間 | 511 ms |
| コンパイル使用メモリ | 82,176 KB |
| 実行使用メモリ | 65,152 KB |
| 最終ジャッジ日時 | 2024-12-27 13:54:19 |
| 合計ジャッジ時間 | 5,379 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | RE * 4 |
| other | RE * 40 |
ソースコード
from atcoder.scc import SCCGraph
N = int(input())
M, A = [], []
scc = SCCGraph(N)
for i in range(N):
m, *a = map(lambda x: int(x)-1, input().split())
M.append(m)
A.append(a)
for j in a:
scc.add_edge(i, j)
scc = scc.scc()
label = [-1]*N
for i, l in enumerate(scc):
for j in l:
label[j] = i
to = [set() for _ in range(len(scc))]
for i in range(N):
for j in A[i]:
if label[i] != label[j]:
to[label[i]].add(label[j])
cnt_one = sum(len(x) == 1 for x in to)
cnt_zero = sum(len(x) == 0 for x in to)
if cnt_one == len(scc) - 1 and cnt_zero == 1:
print("Yes")
else:
print("No")
寝癖