結果
問題 | No.1639 最小通信路 |
ユーザー | harurun |
提出日時 | 2021-07-11 21:08:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 153 ms / 2,000 ms |
コード長 | 2,996 bytes |
コンパイル時間 | 178 ms |
コンパイル使用メモリ | 82,504 KB |
実行使用メモリ | 79,280 KB |
最終ジャッジ日時 | 2024-09-17 01:00:45 |
合計ジャッジ時間 | 6,276 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
54,272 KB |
testcase_01 | AC | 66 ms
68,864 KB |
testcase_02 | AC | 140 ms
76,800 KB |
testcase_03 | AC | 153 ms
78,976 KB |
testcase_04 | AC | 140 ms
79,280 KB |
testcase_05 | AC | 104 ms
76,384 KB |
testcase_06 | AC | 120 ms
76,632 KB |
testcase_07 | AC | 69 ms
70,016 KB |
testcase_08 | AC | 120 ms
76,572 KB |
testcase_09 | AC | 77 ms
74,112 KB |
testcase_10 | AC | 95 ms
76,416 KB |
testcase_11 | AC | 125 ms
76,768 KB |
testcase_12 | AC | 109 ms
76,032 KB |
testcase_13 | AC | 148 ms
76,928 KB |
testcase_14 | AC | 70 ms
68,480 KB |
testcase_15 | AC | 104 ms
76,304 KB |
testcase_16 | AC | 118 ms
76,500 KB |
testcase_17 | AC | 135 ms
77,056 KB |
testcase_18 | AC | 91 ms
75,904 KB |
testcase_19 | AC | 113 ms
76,120 KB |
testcase_20 | AC | 132 ms
76,672 KB |
testcase_21 | AC | 57 ms
63,104 KB |
testcase_22 | AC | 105 ms
76,268 KB |
testcase_23 | AC | 123 ms
76,652 KB |
testcase_24 | AC | 102 ms
76,800 KB |
testcase_25 | AC | 98 ms
76,416 KB |
testcase_26 | AC | 88 ms
75,648 KB |
testcase_27 | AC | 68 ms
69,248 KB |
testcase_28 | AC | 77 ms
68,864 KB |
testcase_29 | AC | 136 ms
77,440 KB |
testcase_30 | AC | 125 ms
77,952 KB |
testcase_31 | AC | 88 ms
76,488 KB |
testcase_32 | AC | 126 ms
77,756 KB |
testcase_33 | AC | 91 ms
76,424 KB |
testcase_34 | AC | 124 ms
77,568 KB |
testcase_35 | AC | 147 ms
78,592 KB |
testcase_36 | AC | 122 ms
77,652 KB |
testcase_37 | AC | 120 ms
77,940 KB |
testcase_38 | AC | 75 ms
71,808 KB |
testcase_39 | AC | 113 ms
76,608 KB |
testcase_40 | AC | 89 ms
75,136 KB |
testcase_41 | AC | 76 ms
71,936 KB |
testcase_42 | AC | 127 ms
77,708 KB |
testcase_43 | AC | 90 ms
75,264 KB |
testcase_44 | AC | 68 ms
70,776 KB |
ソースコード
class INPUT: def __init__(self): self._l=open(0).read().split() self._length=len(self._l) self._index=0 return def stream(self,k=1,f=int,f2=False): assert(-1<k) if self._length==self._index or self._length-self._index<k: raise Exception("There is no input!") elif f!=str: if k==0: ret=list(map(f,self._l[self._index:])) self._index=self._length return ret if k==1 and not f2: ret=f(self._l[self._index]) self._index+=1 return ret if k==1 and f2: ret=[f(self._l[self._index])] self._index+=1 return ret ret=[] for _ in [0]*k: ret.append(f(self._l[self._index])) self._index+=1 return ret else: if k==0: ret=list(self._l[self._index:]) self._index=self._length return ret if k==1 and not f2: ret=self._l[self._index] self._index+=1 return ret if k==1 and f2: ret=[self._l[self._index]] self._index+=1 return ret ret=[] for _ in [0]*k: ret.append(self._l[self._index]) self._index+=1 return ret pin=INPUT().stream #pin(number[default:1],f[default:int],f2[default:False]) #if number==0 -> return left all #listを変数で受け取るとき、必ずlistをTrueにすること。 class dsu: def __init__(self,n): assert n>0,"n must be Natural" self.n=n self.parents=[-1]*n return def find(self,x): assert x<self.n,"warning!! this is 0 index" if self.parents[x]<0: return x self.parents[x]=self.find(self.parents[x]) return self.parents[x] def merge(self,x,y): assert x<self.n and y<self.n,"warning!! this is 0 index" x=self.find(x) y=self.find(y) if x==y: return if self.parents[x]>self.parents[y]: x,y=y,x self.parents[x]+=self.parents[y] self.parents[y]=x return def size(self,x): assert x<self.n,"warning!! this is 0 index" return -self.parents[self.find(x)] def same(self,x,y): assert x<self.n and y<self.n,"warning!! this is 0 index" return self.find(x)==self.find(y) def leader(self,x): assert x<self.n,"warning!! this is 0 index" if self.parents[x]<0: return x self.parents[x]=self.leader(self.parents[x]) return self.parents[x] def groups(self): ld=[self.leader(i) for i in range(self.n)] res=[[] for _ in range(self.n)] for i in range(self.n): res[ld[i]].append(i) return list(filter(lambda a:a !=[],res)) def main(): N=pin(1) d=[[-1]*N for _ in[0]*N] for _ in [0]*(N*(N-1)//2): a,b,C=pin(3) d[a-1][b-1]=C d[b-1][a-1]=C small=1 big=pow(10,100) for _ in [0]*400: mid=(small+big)//2 uf=dsu(N) for i in range(N): for j in range(i+1,N): if d[i][j]<=mid: uf.merge(i,j) if uf.size(0)==N: big=mid else: small=mid print(big) return main()