結果

問題 No.2871 Universal Serial Bus
ユーザー timi
提出日時 2024-09-06 21:48:41
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 40 ms / 2,000 ms
コード長 693 bytes
コンパイル時間 199 ms
コンパイル使用メモリ 82,464 KB
実行使用メモリ 53,512 KB
最終ジャッジ日時 2024-09-06 21:49:04
合計ジャッジ時間 1,666 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 18
権限があれば一括ダウンロードができます

ソースコード

diff #

H,W=map(int,input().split())
# A=list(map(int, input().split()))

A=[]
for i in range(H):
  s=input()
  A.append(s)
  
B=[]
for i in range(H):
  s=input()
  B.append(s)
  
p,q=1,1
for h in range(H):
  for w in range(W):
    if A[h][w]==B[h][w]:
      p=0 
    if A[h][w]==B[-1-h][-1-w]:
      q=0 

ans=3.5317401904617327
if p==0 and q==0:
  print(-1)
elif p==1 and q==0:
  ans=0;p=1
  for i in range(100):
    ans+=p
    if i%2==0:
      q=pow(2,i)
      p/=q 
  print(ans)
elif p==0 and q==1:
  ans=0;p=1
  for i in range(100):
    ans+=p
    if i%2==1:
      q=pow(2,i)
      p/=q 
  print(ans)
else:
  ans=0;p=1
  for i in range(100):
    ans+=p
    q=pow(2,i)
    p/=q 
  print(ans)
  
  
0