結果
| 問題 | No.1170 Never Want to Walk | 
| コンテスト | |
| ユーザー |  | 
| 提出日時 | 2025-10-07 20:27:08 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                WA
                                 
                             | 
| 実行時間 | - | 
| コード長 | 1,273 bytes | 
| コンパイル時間 | 337 ms | 
| コンパイル使用メモリ | 82,856 KB | 
| 実行使用メモリ | 266,304 KB | 
| 最終ジャッジ日時 | 2025-10-07 20:27:16 | 
| 合計ジャッジ時間 | 7,808 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | WA * 2 | 
| other | WA * 13 RE * 13 TLE * 1 -- * 10 | 
ソースコード
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 x-upTox > B:
                    break
                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()
            
            
            
        