結果
問題 | No.1451 集団登校 |
ユーザー | shiomusubi496 |
提出日時 | 2021-03-25 10:57:45 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
RE
|
実行時間 | - |
コード長 | 681 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 10,968 KB |
実行使用メモリ | 44,784 KB |
最終ジャッジ日時 | 2023-08-18 00:51:01 |
合計ジャッジ時間 | 3,968 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
7,804 KB |
testcase_01 | AC | 16 ms
7,836 KB |
testcase_02 | AC | 16 ms
7,792 KB |
testcase_03 | AC | 16 ms
7,812 KB |
testcase_04 | AC | 16 ms
7,872 KB |
testcase_05 | AC | 16 ms
7,796 KB |
testcase_06 | AC | 16 ms
7,792 KB |
testcase_07 | AC | 16 ms
7,800 KB |
testcase_08 | AC | 767 ms
44,784 KB |
testcase_09 | AC | 16 ms
7,904 KB |
testcase_10 | RE | - |
testcase_11 | AC | 172 ms
38,952 KB |
testcase_12 | RE | - |
testcase_13 | RE | - |
testcase_14 | RE | - |
testcase_15 | RE | - |
testcase_16 | RE | - |
testcase_17 | RE | - |
testcase_18 | RE | - |
testcase_19 | AC | 93 ms
26,776 KB |
testcase_20 | RE | - |
testcase_21 | RE | - |
testcase_22 | RE | - |
testcase_23 | RE | - |
testcase_24 | RE | - |
testcase_25 | RE | - |
testcase_26 | RE | - |
testcase_27 | RE | - |
testcase_28 | RE | - |
testcase_29 | RE | - |
ソースコード
mod=1000000007 N,M=map(int,input().split()) st=[{i}for i in range(N)] root=[i for i in range(N)] ans=[1 for i in range(N)] for i in range(M): A,B=map(int,input().split()) A=root[A-1] B=root[B-1] if A==B: continue if len(st[A])<len(st[B]): swap(A,B) if len(st[A])!=len(st[B]): for i in st[B]: ans[i]=0 root[i]=A st[A].add(i) st[B]={} else: for i in st[A]: ans[i]*=500000004 ans[i]%=mod for i in st[B]: ans[i]*=500000004 ans[i]%=mod root[i]=A st[A].add(i) st[B]={} for i in ans: print(i)