結果
| 問題 |
No.2923 Mayor's Job
|
| コンテスト | |
| ユーザー |
YuuuT
|
| 提出日時 | 2024-10-12 17:02:53 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,108 bytes |
| コンパイル時間 | 1,151 ms |
| コンパイル使用メモリ | 82,468 KB |
| 実行使用メモリ | 236,800 KB |
| 最終ジャッジ日時 | 2024-10-12 17:03:32 |
| 合計ジャッジ時間 | 3,576 ms |
|
ジャッジサーバーID (参考情報) |
judge / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 5 WA * 12 |
ソースコード
# oj t -c "python3 main.py"
import sys,math
from collections import defaultdict,deque
from itertools import combinations,permutations,accumulate,product
from bisect import bisect_left,bisect_right
from heapq import heappop,heappush,heapify
#from more_itertools import distinct_permutations,distinct_combinations
#from sortedcontainers import SortedList,SortedSet
def input():return sys.stdin.readline().rstrip()
def ii(): return int(input())
def ms(): return map(int, input().split())
def li(): return list(map(int,input().split()))
inf = pow(10,18)
mod = 998244353
#/////////////////////////////////
N,K = ms()
KK = K*K
G = [set() for _ in range(N+1)]
H = li()
H.sort()
indeg = [0]*N
XY = [li() for _ in range(N)]
for i in range(N):
for j in range(i+1,N):
if H[i]<H[j] and pow(XY[i][0]-XY[j][0],2) + pow(XY[i][1]-XY[j][1],2) <= KK:
G[j].add(i)
indeg[i] += 1
vis = [False]*N
def dfs(v):
vis[v] = True
for v2 in G[v]:
if vis[v2]: continue
dfs(v2)
ans = N
for v in range(N):
if indeg[v]!=0: continue
dfs(v)
vis[v] = True
print(N-vis.count(True)+indeg.count(0))
YuuuT