結果
問題 | No.2696 Sign Creation |
ユーザー | mo124121 |
提出日時 | 2024-02-04 09:50:51 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,699 bytes |
コンパイル時間 | 185 ms |
コンパイル使用メモリ | 82,032 KB |
実行使用メモリ | 96,096 KB |
最終ジャッジ日時 | 2024-05-17 18:09:04 |
合計ジャッジ時間 | 17,087 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
63,152 KB |
testcase_01 | AC | 39 ms
55,380 KB |
testcase_02 | WA | - |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 48 ms
63,324 KB |
testcase_07 | AC | 40 ms
56,124 KB |
testcase_08 | WA | - |
testcase_09 | AC | 73 ms
76,512 KB |
testcase_10 | WA | - |
testcase_11 | AC | 89 ms
76,960 KB |
testcase_12 | AC | 90 ms
76,992 KB |
testcase_13 | WA | - |
testcase_14 | AC | 648 ms
94,088 KB |
testcase_15 | AC | 647 ms
92,060 KB |
testcase_16 | WA | - |
testcase_17 | AC | 94 ms
77,168 KB |
testcase_18 | AC | 322 ms
84,156 KB |
testcase_19 | AC | 775 ms
92,956 KB |
testcase_20 | AC | 108 ms
77,332 KB |
testcase_21 | AC | 437 ms
95,200 KB |
testcase_22 | AC | 513 ms
82,332 KB |
testcase_23 | AC | 571 ms
93,828 KB |
testcase_24 | AC | 524 ms
93,416 KB |
testcase_25 | AC | 992 ms
91,596 KB |
testcase_26 | AC | 235 ms
78,464 KB |
testcase_27 | AC | 619 ms
85,456 KB |
testcase_28 | AC | 500 ms
87,528 KB |
testcase_29 | AC | 120 ms
77,896 KB |
testcase_30 | WA | - |
testcase_31 | TLE | - |
testcase_32 | -- | - |
testcase_33 | -- | - |
testcase_34 | -- | - |
testcase_35 | -- | - |
testcase_36 | -- | - |
testcase_37 | -- | - |
testcase_38 | -- | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
ソースコード
import sys sys.setrecursionlimit(2 * 10**3) if sys.implementation.name == "pypy": import pypyjit pypyjit.set_param("max_unroll_recursion=-1") from collections import defaultdict class UnionFind: def __init__(self, N): self.N = N self.parent_or_size = [-1] * N self.group_count = N def root(self, x): if self.parent_or_size[x] < 0: return x else: self.parent_or_size[x] = self.root(self.parent_or_size[x]) return self.parent_or_size[x] def unite(self, x, y): root_x = self.root(x) root_y = self.root(y) if root_x == root_y: return if -self.parent_or_size[root_x] < -self.parent_or_size[root_y]: root_x, root_y = root_y, root_x self.parent_or_size[root_x] += self.parent_or_size[root_y] self.parent_or_size[root_y] = root_x self.group_count -= 1 def same(self, x, y): return self.root(x) == self.root(y) def size(self, x): return -self.parent_or_size[self.root(x)] def groups(self): ret = defaultdict(list) for i in range(self.N): ret[self.root(i)].append(i) return [group for group in ret.values()] input = lambda: sys.stdin.readline().rstrip() SHIFT = 20 MASK = (1 << SHIFT) - 1 def conv(x, y): return x << SHIFT | y def rev(pos): return pos >> SHIFT, pos & MASK H, W, N, D = map(int, input().split()) star = {} XY = [] for i in range(N): x, y = map(int, input().split()) XY.append((x, y)) star[conv(x, y)] = i uf = UnionFind(N) cand = set() for i, (x, y) in enumerate(XY): for xd in range(-D, D + 1): for yd in range(-D, D + 1): d = abs(xd) + abs(yd) if d > D: continue xn = x + xd yn = y + yd cand.add(conv(xn, yn)) posn = conv(xn, yn) if posn in star: uf.unite(i, star[posn]) stella = uf.groups() is_seiza = [0] * N count = 0 for block in stella: if len(block) > 1: count += 1 for i in block: is_seiza[i] = 1 mi = count ma = count for pos in cand: x, y = rev(pos) seen = set() for xd in range(-D, D + 1): for yd in range(-D, D + 1): d = abs(xd) + abs(yd) if d > D: continue xn = x + xd yn = y + yd posn = conv(xn, yn) if posn not in star: continue seen.add(uf.root(star[posn])) c = count + 1 for s in seen: if is_seiza[s]: c -= 1 mi = min(mi, c) ma = max(ma, c) print(mi, ma)