結果
問題 | No.421 しろくろチョコレート |
ユーザー | Navier_Boltzmann |
提出日時 | 2023-06-17 14:07:58 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,560 bytes |
コンパイル時間 | 172 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 78,208 KB |
最終ジャッジ日時 | 2024-06-25 04:48:05 |
合計ジャッジ時間 | 6,860 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
56,960 KB |
testcase_01 | WA | - |
testcase_02 | AC | 67 ms
70,528 KB |
testcase_03 | WA | - |
testcase_04 | AC | 66 ms
68,992 KB |
testcase_05 | WA | - |
testcase_06 | AC | 53 ms
63,488 KB |
testcase_07 | WA | - |
testcase_08 | AC | 67 ms
71,296 KB |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 47 ms
56,192 KB |
testcase_13 | AC | 46 ms
55,936 KB |
testcase_14 | AC | 45 ms
56,448 KB |
testcase_15 | AC | 45 ms
56,064 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 46 ms
55,936 KB |
testcase_20 | WA | - |
testcase_21 | WA | - |
testcase_22 | WA | - |
testcase_23 | AC | 45 ms
56,192 KB |
testcase_24 | AC | 45 ms
56,192 KB |
testcase_25 | AC | 45 ms
55,936 KB |
testcase_26 | AC | 46 ms
55,936 KB |
testcase_27 | AC | 47 ms
56,448 KB |
testcase_28 | AC | 92 ms
77,532 KB |
testcase_29 | AC | 98 ms
77,300 KB |
testcase_30 | WA | - |
testcase_31 | AC | 80 ms
77,696 KB |
testcase_32 | AC | 97 ms
77,460 KB |
testcase_33 | WA | - |
testcase_34 | AC | 61 ms
68,352 KB |
testcase_35 | AC | 63 ms
68,480 KB |
testcase_36 | WA | - |
testcase_37 | WA | - |
testcase_38 | WA | - |
testcase_39 | WA | - |
testcase_40 | AC | 75 ms
74,592 KB |
testcase_41 | AC | 59 ms
66,944 KB |
testcase_42 | WA | - |
testcase_43 | WA | - |
testcase_44 | AC | 80 ms
77,312 KB |
testcase_45 | WA | - |
testcase_46 | AC | 59 ms
67,200 KB |
testcase_47 | WA | - |
testcase_48 | AC | 79 ms
77,568 KB |
testcase_49 | WA | - |
testcase_50 | WA | - |
testcase_51 | AC | 84 ms
77,836 KB |
testcase_52 | WA | - |
testcase_53 | AC | 62 ms
68,096 KB |
testcase_54 | AC | 69 ms
71,552 KB |
testcase_55 | WA | - |
testcase_56 | WA | - |
testcase_57 | WA | - |
testcase_58 | WA | - |
testcase_59 | WA | - |
testcase_60 | WA | - |
testcase_61 | WA | - |
testcase_62 | AC | 47 ms
56,192 KB |
testcase_63 | AC | 46 ms
56,576 KB |
testcase_64 | AC | 57 ms
66,304 KB |
ソースコード
from collections import * from itertools import * from functools import * from heapq import * import sys,math input = sys.stdin.readline class DSU: def __init__(self, n): self._n = n self.parent_or_size = [-1] * n self.member = [[i] for i in range(n)] def merge(self, a, b): assert 0 <= a < self._n assert 0 <= b < self._n x, y = self.leader(a), self.leader(b) if x == y: return x if -self.parent_or_size[x] < -self.parent_or_size[y]: x, y = y, x self.parent_or_size[x] += self.parent_or_size[y] for tmp in self.member[y]: self.member[x].append(tmp) self.parent_or_size[y] = x return x def members(self,a): return self.member[self.leader(a)] def same(self, a, b): assert 0 <= a < self._n assert 0 <= b < self._n return self.leader(a) == self.leader(b) def leader(self, a): assert 0 <= a < self._n if self.parent_or_size[a] < 0: return a self.parent_or_size[a] = self.leader(self.parent_or_size[a]) return self.parent_or_size[a] def size(self, a): assert 0 <= a < self._n return -self.parent_or_size[self.leader(a)] def groups(self): leader_buf = [self.leader(i) for i in range(self._n)] result = [[] for _ in range(self._n)] for i in range(self._n): result[leader_buf[i]].append(i) return [r for r in result if r != []] N,M = map(int,input().split()) S = [list(input())[:-1] for _ in range(N)] H,W = N,M if H>W: H,W = W,H S = list(zip(*S)) def nb(x,y): tmp = [] if x+1<H: tmp.append((x+1,y)) if x-1>=0: tmp.append((x-1,y)) if y+1<W: tmp.append((x,y+1)) if y-1>=0: tmp.append((x,y-1)) return tmp D = DSU(N*M) for i in range(H): for j in range(W): if S[i][j]=='.': continue for ix,iy in nb(i,j): if S[ix][iy]!='.': D.merge(W*ix + iy,W*i+j) C = Counter([]) ans = 0 for g in D.groups(): i,j = divmod(g[0],W) if S[i][j]=='.': continue b = 0 w = 0 for i in g: ix,iy = divmod(i,W) if S[ix][iy]=='w': w += 1 else: b += 1 if b==w: ans += b*100 elif b>w: ans += w*100 C['b'] += b-w else: b,w = w,b ans += w*100 C['w'] += b-w a,b = C['b'],C['w'] M = max(a,b) m = min(a,b) ans += 10*m ans += (M-m) print(ans)