結果
問題 | No.2696 Sign Creation |
ユーザー | nikoro256 |
提出日時 | 2024-03-23 00:23:19 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 2,631 bytes |
コンパイル時間 | 208 ms |
コンパイル使用メモリ | 82,628 KB |
実行使用メモリ | 94,220 KB |
最終ジャッジ日時 | 2024-05-17 18:21:59 |
合計ジャッジ時間 | 9,125 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
64,272 KB |
testcase_01 | AC | 47 ms
63,788 KB |
testcase_02 | AC | 41 ms
56,244 KB |
testcase_03 | AC | 43 ms
60,748 KB |
testcase_04 | AC | 40 ms
56,572 KB |
testcase_05 | AC | 41 ms
61,000 KB |
testcase_06 | AC | 39 ms
56,152 KB |
testcase_07 | AC | 40 ms
55,352 KB |
testcase_08 | AC | 124 ms
77,836 KB |
testcase_09 | AC | 68 ms
74,964 KB |
testcase_10 | AC | 117 ms
78,280 KB |
testcase_11 | AC | 73 ms
76,512 KB |
testcase_12 | AC | 75 ms
76,400 KB |
testcase_13 | AC | 556 ms
83,336 KB |
testcase_14 | AC | 307 ms
83,504 KB |
testcase_15 | AC | 299 ms
83,400 KB |
testcase_16 | AC | 565 ms
83,440 KB |
testcase_17 | AC | 180 ms
77,764 KB |
testcase_18 | AC | 167 ms
78,672 KB |
testcase_19 | AC | 273 ms
81,136 KB |
testcase_20 | AC | 87 ms
77,216 KB |
testcase_21 | AC | 259 ms
85,780 KB |
testcase_22 | AC | 265 ms
79,136 KB |
testcase_23 | AC | 295 ms
82,680 KB |
testcase_24 | AC | 293 ms
82,304 KB |
testcase_25 | AC | 341 ms
81,180 KB |
testcase_26 | AC | 248 ms
78,812 KB |
testcase_27 | AC | 168 ms
78,228 KB |
testcase_28 | AC | 180 ms
78,516 KB |
testcase_29 | AC | 204 ms
77,812 KB |
testcase_30 | AC | 207 ms
78,156 KB |
testcase_31 | AC | 1,514 ms
94,220 KB |
testcase_32 | AC | 45 ms
61,188 KB |
testcase_33 | AC | 59 ms
69,508 KB |
testcase_34 | AC | 50 ms
65,856 KB |
testcase_35 | AC | 37 ms
55,268 KB |
testcase_36 | AC | 39 ms
55,892 KB |
testcase_37 | AC | 38 ms
54,544 KB |
testcase_38 | AC | 38 ms
54,792 KB |
testcase_39 | WA | - |
testcase_40 | AC | 40 ms
56,304 KB |
ソースコード
from collections import defaultdict class UnionFind(): def __init__(self, n): self.n = n self.parents = [-1] * n def find(self, x): way=[] while True: if self.parents[x] < 0: break else: way.append(x) x=self.parents[x] for w in way: self.parents[w]=x return x def union(self, x, y): x = self.find(x) y = self.find(y) if x == y: return if self.parents[x] > self.parents[y]: x, y = y, x self.parents[x] += self.parents[y] self.parents[y] = x def size(self, x): return -self.parents[self.find(x)] def same(self, x, y): return self.find(x) == self.find(y) 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 all_group_members(self): group_members = defaultdict(list) for member in range(self.n): group_members[self.find(member)].append(member) return group_members def __str__(self): return '\n'.join(f'{r}: {m}' for r, m in self.all_group_members().items()) import sys input=sys.stdin.readline H,W,N,D=map(int,input().split()) dat=[] datset=set() dic=[[-1]*(W+10) for _ in range(H+10)] uf=UnionFind(N) for i in range(N): x,y=map(int,input().split()) x-=1 y-=1 dat.append((x,y)) datset.add((x,y)) dic[x][y]=i for x,y in dat: for i in range(D+1): lim=D-abs(i) for j in range(-lim,lim+1): if dic[x+i][y+j]!=-1: uf.union(dic[x][y],dic[x+i][y+j]) small=10**9 big=-10**9 for i in range(H): for j in range(W): use=set() for k in range(-D,D+1): lim=D-abs(k) for t in range(-lim,lim+1): tmp=(i+k,j+t) if dic[i+k][j+t]!=-1: use.add(uf.find(dic[i+k][j+t])) flag=False one=0 notone=0 tmp=0 for u in use: if -uf.parents[u]==1: one+=1 else: notone+=1 if notone==0: if one>0: tmp+=1 else: tmp=-(notone-1) big=max(big,tmp) small=min(small,tmp) all=0 #print(small,big) for idx,lis in uf.all_group_members().items(): if len(lis)>1: all+=1 #print(all) print(all+small,all+big)