結果
| 問題 | No.2780 The Bottle Imp |
| コンテスト | |
| ユーザー |
寝癖
|
| 提出日時 | 2024-06-07 22:16:43 |
| 言語 | PyPy3 (7.3.17) |
| 結果 |
RE
|
| 実行時間 | - |
| コード長 | 642 bytes |
| 記録 | |
| コンパイル時間 | 355 ms |
| コンパイル使用メモリ | 85,376 KB |
| 実行使用メモリ | 65,792 KB |
| 最終ジャッジ日時 | 2026-06-02 02:36:42 |
| 合計ジャッジ時間 | 3,575 ms |
|
ジャッジサーバーID (参考情報) |
judge3_0 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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")
寝癖