Linux tsuru-no-tsurugi 5.15.0-186-generic #196-Ubuntu SMP Sat Jun 20 16:09:34 UTC 2026 x86_64
Apache/2.4.52 (Ubuntu)
Server IP : 192.168.0.18 & Your IP : 216.73.217.105
Domains :
Cant Read [ /etc/named.conf ]
User : www-data
Terminal
Auto Root
Create File
Create Folder
Localroot Suggester
Backdoor Destroyer
Readme
/
var /
www /
submit2 /
114838 /
Delete
Unzip
Name
Size
Permission
Date
Action
a.py
1.72
KB
-rwxr-x---
2024-08-28 22:35
cerror.txt
0
B
-rwxr-x---
2024-08-28 22:35
error.txt
0
B
-rwxr-x---
2024-08-28 22:35
submit_info.txt
186
B
-rwxr-x---
2024-08-28 22:35
Save
Rename
import sys sys.setrecursionlimit(200000) # UnionFind class UnionFind: def __init__(self, n): self.par = [-1] * n self.S = n def root(self, A): if self.par[A] < 0: return A self.par[A] = self.root(self.par[A]) return self.par[A] def same(self, A, B): return self.root(A) == self.root(B) def unite(self, A, B): a = self.root(A) b = self.root(B) if a == b: return False if self.par[a] > self.par[b]: a, b = b, a self.par[a] += self.par[b] self.par[b] = a self.S -= 1 return True def size(self, A): return -self.par[self.root(A)] def size(self): return self.S # main N, M, X, P = map(int, input().split()) B = list(map(int, input().split())) T = list(map(int, input().split())) # assert(1 <= N and N <= 100) # assert(1 <= M and M <= 100000) # assert(1 <= X and X <= 100000) # assert(1 <= P and P <= 1000000000) # assert(len(B) == N) # assert(len(T) == M) #for i in range(N): # assert(1 <= B[i] and B[i] <= 1000000000) #for i in range(M): # assert(1 <= T[i] and T[i] <= 1000000000) UF = UnionFind(M + 100) while True: try: u, v = map(int, input().split()) #assert(1 <= u and u <= M) #assert(1 <= v and v <= M) u -= 1 v -= 1 UF.unite(u, v) except: break ok = True try: u,v = map(int, input().split()) ok = False except: pass assert(ok) ans = 0 for i in range(M): dis = 10**18 for j in range(N): dis = min(dis, abs(B[j] - T[i])) if dis <= P: if UF.unite(i, M): ans += 1 print(ans)