結果
問題 |
No.1170 Never Want to Walk
|
ユーザー |
|
提出日時 | 2025-10-07 18:50:55 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,247 bytes |
コンパイル時間 | 284 ms |
コンパイル使用メモリ | 12,160 KB |
実行使用メモリ | 10,496 KB |
最終ジャッジ日時 | 2025-10-07 18:51:07 |
合計ジャッジ時間 | 7,849 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 25 TLE * 1 -- * 11 |
ソースコード
class stationConectivity(): def __init__(self, num_station): self.parent = [-1]*(num_station) def find(self, id): if self.parent[id]<0: return id else: self.parent[id] = self.find(self.parent[id]) return self.parent[id] def union(self, xi, A, B): for i, x in enumerate(xi): for j, upTox in enumerate(xi[:i]): if A <= x-upTox <= B: x_root = self.find(i) upTox_root = self.find(j) if x_root != upTox_root: if self.parent[x_root] > self.parent[upTox_root]: x_root, upTox_root = upTox_root, x_root self.parent[x_root] += self.parent[upTox_root] self.parent[upTox_root] = x_root def countReachable(self, id): return self.parent[self.find(id)]*-1 def main(): num_station, A, B = map(int, input().split()) xi = list(map(int, input().split())) railway = stationConectivity(num_station) railway.union(xi, A, B) for i in range(num_station): print(railway.countReachable(i)) if __name__ == "__main__": main() """ 5 4 6 0 2 5 7 8 """