結果
問題 | No.1170 Never Want to Walk |
ユーザー | terasa |
提出日時 | 2022-05-24 02:11:21 |
言語 | PyPy3 (7.3.15) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,974 bytes |
コンパイル時間 | 207 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 106,144 KB |
最終ジャッジ日時 | 2024-09-20 13:30:50 |
合計ジャッジ時間 | 13,802 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
60,288 KB |
testcase_01 | AC | 45 ms
54,912 KB |
testcase_02 | AC | 45 ms
55,424 KB |
testcase_03 | AC | 45 ms
55,296 KB |
testcase_04 | AC | 44 ms
55,168 KB |
testcase_05 | AC | 45 ms
55,296 KB |
testcase_06 | AC | 44 ms
55,040 KB |
testcase_07 | AC | 45 ms
55,296 KB |
testcase_08 | AC | 45 ms
54,912 KB |
testcase_09 | AC | 45 ms
55,040 KB |
testcase_10 | AC | 45 ms
54,912 KB |
testcase_11 | AC | 44 ms
54,784 KB |
testcase_12 | AC | 80 ms
75,904 KB |
testcase_13 | AC | 86 ms
76,800 KB |
testcase_14 | AC | 88 ms
77,312 KB |
testcase_15 | AC | 80 ms
76,032 KB |
testcase_16 | AC | 83 ms
76,032 KB |
testcase_17 | AC | 96 ms
76,672 KB |
testcase_18 | AC | 87 ms
76,416 KB |
testcase_19 | AC | 83 ms
76,160 KB |
testcase_20 | AC | 91 ms
76,928 KB |
testcase_21 | AC | 81 ms
76,160 KB |
testcase_22 | AC | 389 ms
77,184 KB |
testcase_23 | AC | 181 ms
77,300 KB |
testcase_24 | AC | 392 ms
77,008 KB |
testcase_25 | AC | 396 ms
77,312 KB |
testcase_26 | AC | 277 ms
76,728 KB |
testcase_27 | AC | 972 ms
101,700 KB |
testcase_28 | AC | 943 ms
101,784 KB |
testcase_29 | AC | 839 ms
104,168 KB |
testcase_30 | AC | 960 ms
103,812 KB |
testcase_31 | AC | 888 ms
101,560 KB |
testcase_32 | TLE | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
ソースコード
import sys import pypyjit import itertools import heapq import math from collections import deque, defaultdict, Counter import bisect input = sys.stdin.readline sys.setrecursionlimit(10 ** 6) pypyjit.set_param('max_unroll_recursion=-1') class UnionFind: def __init__(self, N): self.N = N self.par = [-1] * N def find(self, x): if self.par[x] < 0: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def unite(self, x, y): x = self.find(x) y = self.find(y) if x == y: return False if x > y: x, y = y, x self.par[x] += self.par[y] self.par[y] = x return True def same(self, x, y): return self.find(x) == self.find(y) def size(self, x): return -self.par[self.find(x)] def roots(self): return [i for i in range(self.N) if self.par[i] < 0] def members(self, x): p = self.find(x) return [i for i in range(self.N) if self.find(i) == p] def index_lt(a, x): 'return largest index s.t. A[i] < x or -1 if it does not exist' return bisect.bisect_left(a, x) - 1 def index_le(a, x): 'return largest index s.t. A[i] <= x or -1 if it does not exist' return bisect.bisect_right(a, x) - 1 def index_gt(a, x): 'return smallest index s.t. A[i] > x or len(a) if it does not exist' return bisect.bisect_right(a, x) def index_ge(a, x): 'return smallest index s.t. A[i] > x or len(a) if it does not exist' return bisect.bisect_left(a, x) N, A, B = map(int, input().split()) X = list(map(int, input().split())) uf = UnionFind(N) for i, x in enumerate(X): a = index_ge(X, x - B) b = index_le(X, x - A) c = index_ge(X, x + A) d = index_le(X, x + B) for j in range(a, b + 1): uf.unite(i, j) for j in range(c, d + 1): uf.unite(i, j) for i in range(N): print(uf.size(i))