結果
問題 | No.1451 集団登校 |
ユーザー | 👑 rin204 |
提出日時 | 2022-04-15 15:26:06 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 811 bytes |
コンパイル時間 | 352 ms |
コンパイル使用メモリ | 87,168 KB |
実行使用メモリ | 94,184 KB |
最終ジャッジ日時 | 2023-08-26 05:43:50 |
合計ジャッジ時間 | 7,516 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge11 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 70 ms
71,240 KB |
testcase_01 | AC | 74 ms
71,376 KB |
testcase_02 | AC | 72 ms
70,928 KB |
testcase_03 | AC | 70 ms
71,324 KB |
testcase_04 | AC | 71 ms
71,240 KB |
testcase_05 | AC | 71 ms
71,240 KB |
testcase_06 | AC | 70 ms
71,332 KB |
testcase_07 | AC | 72 ms
71,320 KB |
testcase_08 | AC | 188 ms
93,776 KB |
testcase_09 | AC | 71 ms
71,092 KB |
testcase_10 | WA | - |
testcase_11 | AC | 185 ms
88,932 KB |
testcase_12 | WA | - |
testcase_13 | WA | - |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 145 ms
84,296 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
ソースコード
MOD = 10 ** 9 + 7 n, m = map(int, input().split()) leader = [[i] for i in range(n)] parent = [-1] * n def find(x): if parent[x] < 0: return x parent[x] = find(parent[x]) return parent[x] def unite(x, y): x = find(x) y = find(y) if x == y: return if parent[x] > parent[y]: x, y = y, x parent[x], parent[y] = parent[y], parent[x] leader[x], leader[y] = leader[y], leader[x] elif parent[x] == parent[y]: leader[x] += leader[y] parent[x] += parent[y] parent[y] = x for _ in range(m): a, b = map(int, input().split()) unite(a - 1, b - 1) ans = [0] * n for i in range(n): if parent[i] < 0: x = pow(len(leader[i]), MOD - 2, MOD) for j in leader[i]: ans[j] = x print(*ans, sep="\n")