結果
問題 | No.2946 Puyo |
ユーザー | lif4635 |
提出日時 | 2024-10-25 21:26:25 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 287 ms / 2,000 ms |
コード長 | 2,878 bytes |
コンパイル時間 | 171 ms |
コンパイル使用メモリ | 82,848 KB |
実行使用メモリ | 123,176 KB |
最終ジャッジ日時 | 2024-10-25 21:26:44 |
合計ジャッジ時間 | 10,272 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 41 ms
53,552 KB |
testcase_01 | AC | 38 ms
53,860 KB |
testcase_02 | AC | 36 ms
52,816 KB |
testcase_03 | AC | 220 ms
123,176 KB |
testcase_04 | AC | 228 ms
122,640 KB |
testcase_05 | AC | 208 ms
122,724 KB |
testcase_06 | AC | 208 ms
122,584 KB |
testcase_07 | AC | 220 ms
121,936 KB |
testcase_08 | AC | 75 ms
77,120 KB |
testcase_09 | AC | 124 ms
82,276 KB |
testcase_10 | AC | 93 ms
77,256 KB |
testcase_11 | AC | 138 ms
88,160 KB |
testcase_12 | AC | 78 ms
77,272 KB |
testcase_13 | AC | 38 ms
53,980 KB |
testcase_14 | AC | 134 ms
78,672 KB |
testcase_15 | AC | 109 ms
77,196 KB |
testcase_16 | AC | 138 ms
79,212 KB |
testcase_17 | AC | 222 ms
100,132 KB |
testcase_18 | AC | 101 ms
76,576 KB |
testcase_19 | AC | 170 ms
80,700 KB |
testcase_20 | AC | 206 ms
87,628 KB |
testcase_21 | AC | 233 ms
95,356 KB |
testcase_22 | AC | 125 ms
78,312 KB |
testcase_23 | AC | 208 ms
84,992 KB |
testcase_24 | AC | 287 ms
88,356 KB |
testcase_25 | AC | 248 ms
87,444 KB |
testcase_26 | AC | 259 ms
87,516 KB |
testcase_27 | AC | 111 ms
76,784 KB |
testcase_28 | AC | 171 ms
85,276 KB |
testcase_29 | AC | 193 ms
88,492 KB |
testcase_30 | AC | 160 ms
83,464 KB |
testcase_31 | AC | 182 ms
86,836 KB |
testcase_32 | AC | 189 ms
86,716 KB |
testcase_33 | AC | 183 ms
86,204 KB |
testcase_34 | AC | 201 ms
88,708 KB |
testcase_35 | AC | 187 ms
87,520 KB |
testcase_36 | AC | 197 ms
87,424 KB |
testcase_37 | AC | 192 ms
87,888 KB |
testcase_38 | AC | 176 ms
92,088 KB |
testcase_39 | AC | 170 ms
84,816 KB |
testcase_40 | AC | 148 ms
83,976 KB |
testcase_41 | AC | 199 ms
87,640 KB |
testcase_42 | AC | 184 ms
88,564 KB |
testcase_43 | AC | 151 ms
84,748 KB |
testcase_44 | AC | 164 ms
86,452 KB |
testcase_45 | AC | 158 ms
85,004 KB |
testcase_46 | AC | 140 ms
82,060 KB |
testcase_47 | AC | 168 ms
84,976 KB |
ソースコード
#int-input def II(): return int(input()) def MI() -> int : return map(int, input().split()) class fenwick_tree(): n=1 data=[0 for i in range(n)] def __init__(self,N): self.n=N self.data=[0 for i in range(N)] def add(self,p,x): assert 0<=p<self.n,"0<=p<n,p={0},n={1}".format(p,self.n) p+=1 while(p<=self.n): self.data[p-1]+=x p+=p& -p def sum(self,l,r): assert (0<=l and l<=r and r<=self.n),"0<=l<=r<=n,l={0},r={1},n={2}".format(l,r,self.n) return self.sum0(r)-self.sum0(l) def sum0(self,r): s=0 while(r>0): s+=self.data[r-1] r-=r&-r return s class dsu(): n=1 parent_or_size=[-1 for i in range(n)] def __init__(self,N): self.n=N self.parent_or_size=[-1 for i in range(N)] def merge(self,a,b): assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n) assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n) x=self.leader(a) y=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] self.parent_or_size[y]=x return x def same(self,a,b): assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(a,self.n) assert 0<=b<self.n, "0<=b<n,b={0},n={1}".format(b,self.n) return self.leader(a)==self.leader(b) def leader(self,a): assert 0<=a<self.n, "0<=a<n,a={0},n={1}".format(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, "0<=a<n,a={0},n={1}".format(a,self.n) return -self.parent_or_size[self.leader(a)] def groups(self): leader_buf=[0 for i in range(self.n)] group_size=[0 for i in range(self.n)] for i in range(self.n): leader_buf[i]=self.leader(i) group_size[leader_buf[i]]+=1 result=[[] for i in range(self.n)] for i in range(self.n): result[leader_buf[i]].append(i) result2=[] for i in range(self.n): if len(result[i])>0: result2.append(result[i]) return result2 h,w = MI() g = [input() for i in range(h)] ans = [[""]*w for i in range(h)] uf = dsu(h*w) for i in range(h): for j in range(w): if i != h-1 and g[i][j] == g[i+1][j]: uf.merge(i*w+j,(i+1)*w+j) if j != w-1 and g[i][j] == g[i][j+1]: uf.merge(i*w+j,i*w+j+1) for i in range(h): for j in range(w): if uf.size(i*w+j) >= 4: ans[i][j] = "." else: ans[i][j] = g[i][j] for i in ans: print("".join(i))