結果
問題 | No.1170 Never Want to Walk |
ユーザー | shotoyoo |
提出日時 | 2020-08-14 21:58:56 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,593 bytes |
コンパイル時間 | 774 ms |
コンパイル使用メモリ | 82,372 KB |
実行使用メモリ | 118,912 KB |
最終ジャッジ日時 | 2024-04-18 21:45:24 |
合計ジャッジ時間 | 8,832 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 37 ms
58,112 KB |
testcase_01 | AC | 37 ms
52,480 KB |
testcase_02 | AC | 36 ms
52,096 KB |
testcase_03 | AC | 37 ms
52,480 KB |
testcase_04 | AC | 37 ms
52,608 KB |
testcase_05 | AC | 37 ms
52,480 KB |
testcase_06 | AC | 36 ms
52,608 KB |
testcase_07 | AC | 38 ms
52,224 KB |
testcase_08 | AC | 37 ms
52,352 KB |
testcase_09 | AC | 37 ms
52,608 KB |
testcase_10 | AC | 38 ms
52,460 KB |
testcase_11 | AC | 38 ms
52,096 KB |
testcase_12 | AC | 51 ms
63,232 KB |
testcase_13 | AC | 64 ms
70,656 KB |
testcase_14 | AC | 73 ms
71,808 KB |
testcase_15 | AC | 56 ms
63,744 KB |
testcase_16 | AC | 55 ms
65,280 KB |
testcase_17 | AC | 67 ms
72,576 KB |
testcase_18 | AC | 51 ms
62,976 KB |
testcase_19 | AC | 53 ms
64,640 KB |
testcase_20 | AC | 65 ms
72,064 KB |
testcase_21 | AC | 54 ms
63,616 KB |
testcase_22 | AC | 188 ms
76,284 KB |
testcase_23 | AC | 106 ms
76,264 KB |
testcase_24 | AC | 196 ms
76,164 KB |
testcase_25 | AC | 189 ms
76,168 KB |
testcase_26 | AC | 153 ms
75,948 KB |
testcase_27 | AC | 410 ms
112,936 KB |
testcase_28 | AC | 417 ms
112,700 KB |
testcase_29 | AC | 373 ms
112,660 KB |
testcase_30 | AC | 444 ms
112,176 KB |
testcase_31 | AC | 388 ms
112,484 KB |
testcase_32 | TLE | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
import sys input = lambda : sys.stdin.readline().rstrip() sys.setrecursionlimit(max(1000, 10**9)) write = lambda x: sys.stdout.write(x+"\n") n,a,b = list(map(int, input().split())) xs = list(map(int, input().split())) ls = [None]*n rs = [None]*n j = 0 for i in range(n): x = xs[i] while j+1<n and xs[j]<x+a: j += 1 if x+a<=xs[j]<=x+b: ls[i] = j j = 0 for i in range(n): x = xs[i] while j+1<n and xs[j+1]<=x+b: j += 1 if x+a<=xs[j]<=x+b: rs[i] = j class UnionFindTree: def __init__(self, n): self.n = n self.parent = list(range(n)) self.size = [1] * n def root(self, i): inter = set() while self.parent[i]!=i: inter.add(i) i = self.parent[i] r = i for i in inter: self.parent[i] = r return r def connect(self, i, j): if i==j: return ri = self.root(i) rj = self.root(j) if ri==rj: return if self.size[ri]<self.size[rj]: self.parent[ri] = rj self.size[rj] += self.size[ri] else: self.parent[rj] = ri self.size[ri] += self.size[rj] uf = UnionFindTree(n) pl, pr = -1, -1 for i, (l,r) in enumerate(zip(ls,rs)): if l is not None and l<=pr: uf.connect(i, i-1) for j in range(pr, r+1): uf.connect(i, j) elif l is not None: for j in range(l, r+1): uf.connect(i, j) else: pass for i in range(n): print(uf.size[uf.root(i)])