結果
| 問題 |
No.2923 Mayor's Job
|
| コンテスト | |
| ユーザー |
prin_kemkem
|
| 提出日時 | 2024-10-12 15:07:31 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 145 ms / 2,000 ms |
| コード長 | 2,888 bytes |
| コンパイル時間 | 234 ms |
| コンパイル使用メモリ | 82,228 KB |
| 実行使用メモリ | 77,568 KB |
| 最終ジャッジ日時 | 2024-10-12 15:07:42 |
| 合計ジャッジ時間 | 2,759 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 17 |
ソースコード
from collections import defaultdict, deque, Counter
# from functools import cache
# import copy
from itertools import combinations, permutations, product, accumulate, groupby, chain
# from more_itertools import distinct_permutations
from heapq import heapify, heappop, heappush
import math
import bisect
# from pprint import pprint
from random import randint, shuffle, randrange
# from sortedcontainers import SortedSet, SortedList, SortedDict
import sys
# sys.setrecursionlimit(2000000)
input = lambda: sys.stdin.readline().rstrip('\n')
inf = float('inf')
mod1 = 10**9+7
mod2 = 998244353
def ceil_div(x, y): return -(-x//y)
#################################################
class UnionFind:
#コンストラクタ
def __init__(self, n):
self.n = n
self.parents = [-1]*n
#点xの根を調べる+親が根になるよう移動
def find(self, x):
if self.parents[x] < 0:
return x
else:
self.parents[x] = self.find(self.parents[x])
return self.parents[x]
#点x,yの属する集合同士を連結(要素数が少ない方を多い方に連結)
#辺を追加したらTrue, しなければFalseを返す
def union(self, x, y):
x = self.find(x)
y = self.find(y)
if x == y:
return False
if self.parents[x] > self.parents[y]:
x, y = y, x
self.parents[x] += self.parents[y]
self.parents[y] = x
return True
#点xが属する集合の要素数を取得
def size(self, x):
return -self.parents[self.find(x)]
#点x,yが同じ集合に属しているか判定
def same(self, x, y):
return self.find(x) == self.find(y)
#点xの属する集合の全要素を取得
def members(self, x):
root = self.find(x)
return [i for i in range(self.n) if self.find(i) == root]
#根になっている全要素を取得
def roots(self):
return [i for i, x in enumerate(self.parents) if x < 0]
#集合の数を取得
def group_count(self):
return len(self.roots())
#全集合の「根と全要素」を取得
def get_groups(self):
groups = defaultdict(list)
for x in range(self.n):
groups[self.find(x)].append(x)
return groups
#print(インスタンス)で、全集合の「根と全要素」を出力
def __str__(self):
return '\n'.join('{}:{}'.format(r, self.menbers(r)) for r in self.roots())
def is_edge(i, j):
if H[i] >= H[j]: return False
ix, iy = P[i]
jx, jy = P[j]
return (ix-jx)**2 + (iy-jy)**2 <= K**2
N, K = map(int, input().split())
H = list(map(int, input().split()))
P = [tuple(map(int, input().split())) for _ in range(N)]
dout = [0]*N
for i in range(N):
for j in range(N):
if is_edge(i, j):
dout[i] += 1
print(dout.count(0))
prin_kemkem