結果
問題 | No.2696 Sign Creation |
ユーザー | mymelochan |
提出日時 | 2024-03-22 22:09:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,437 bytes |
コンパイル時間 | 3,031 ms |
コンパイル使用メモリ | 81,444 KB |
実行使用メモリ | 92,104 KB |
最終ジャッジ日時 | 2024-03-22 22:09:31 |
合計ジャッジ時間 | 9,670 ms |
ジャッジサーバーID (参考情報) |
judge12 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 52 ms
64,316 KB |
testcase_01 | AC | 53 ms
64,048 KB |
testcase_02 | AC | 44 ms
55,596 KB |
testcase_03 | AC | 51 ms
63,648 KB |
testcase_04 | AC | 50 ms
61,788 KB |
testcase_05 | AC | 50 ms
61,532 KB |
testcase_06 | WA | - |
testcase_07 | WA | - |
testcase_08 | AC | 131 ms
77,640 KB |
testcase_09 | WA | - |
testcase_10 | AC | 138 ms
77,736 KB |
testcase_11 | AC | 84 ms
75,944 KB |
testcase_12 | AC | 84 ms
75,816 KB |
testcase_13 | AC | 507 ms
82,612 KB |
testcase_14 | WA | - |
testcase_15 | WA | - |
testcase_16 | AC | 451 ms
81,972 KB |
testcase_17 | AC | 178 ms
76,952 KB |
testcase_18 | WA | - |
testcase_19 | WA | - |
testcase_20 | AC | 100 ms
76,600 KB |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | WA | - |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | WA | - |
testcase_27 | AC | 221 ms
78,500 KB |
testcase_28 | WA | - |
testcase_29 | AC | 186 ms
76,980 KB |
testcase_30 | WA | - |
testcase_31 | AC | 682 ms
92,104 KB |
testcase_32 | AC | 52 ms
63,648 KB |
testcase_33 | AC | 75 ms
72,884 KB |
testcase_34 | AC | 58 ms
66,104 KB |
testcase_35 | AC | 45 ms
55,596 KB |
testcase_36 | AC | 45 ms
55,596 KB |
testcase_37 | AC | 45 ms
55,596 KB |
testcase_38 | AC | 44 ms
55,596 KB |
ソースコード
############################################################# import sys sys.setrecursionlimit(10**7) from heapq import heappop,heappush from collections import deque,defaultdict,Counter from bisect import bisect_left, bisect_right from itertools import product,combinations,permutations ipt = sys.stdin.readline def iin(): return int(ipt()) def lmin(): return list(map(int,ipt().split())) class dsu: def __init__(self,n): self.N = n self.cnt=[1]*self.N self.root=list(range(self.N)) self.components = self.N def unite(self,x,y): x=self.leader(x) y=self.leader(y) if x!=y: self.components -= 1 if self.cnt[x]<self.cnt[y]: x,y=y,x self.cnt[x]+=self.cnt[y] self.root[y]=x return x return None def leader(self,x): if self.root[x]==x: return x self.root[x]=self.leader(self.root[x]) return self.root[x] MOD = 998244353 ############################################################# H,W,N,D = lmin() A = [[-1]*W for _ in range(H)] L = [lmin() for _ in range(N)] for i,(x,y) in enumerate(L): x,y = x-1,y-1 A[x][y] = i uf = dsu(N) for idx,(x,y) in enumerate(L): x,y = x-1,y-1 for i in range(x-D,x+D+1): for j in range(y-D,y+D+1): if 0 <= i < H and 0 <= j < W: if A[i][j] != -1: uf.unite(A[i][j],idx) S = set() T = set() for i in range(N): l = uf.leader(i) if uf.cnt[l] == 1: T.add(l) else: S.add(l) tmp = len(S) #print(S,T) ma = 0 mi = 1<<30 for x in range(H): for y in range(W): if A[x][y] != -1: continue ss = set() tt = set() for i in range(x-D,x+D+1): for j in range(y-D,y+D+1): if 0 <= i < H and 0 <= j < W: if A[i][j] != -1: l = uf.leader(A[i][j]) if l in S: ss.add(l) else: tt.add(l) if not ss: if tt: ma = max(ma, tmp+1) mi = min(mi, tmp+1) else: ma = max(ma, tmp) mi = min(mi, tmp) else: ma = max(ma, tmp-len(ss)+1) mi = min(mi, tmp-len(ss)+1) print(mi,ma)