Advertisement
varyaaas

Untitled

Feb 13th, 2023
672
0
Never
1
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.10 KB | None | 0 0
  1. N = int(input())
  2. str_list_1 = [input() for i in range(N)]
  3. M = int(input())
  4. str_list_2 = [input() for i in range(M)]
  5. cnt_dict_1 = {}
  6. cnt_dict_2 = {}
  7. for i in range(len(str_list_1[0])):
  8.     for j in range(0, N):
  9.         if str_list_1[j][i] == 'A':
  10.             if i not in cnt_dict_1:
  11.                 cnt_dict_1[i] = 1
  12.             else:
  13.                 cnt_dict_1[i] += 1
  14.         else:
  15.             cnt_dict_1[i] = 0
  16. i, j = 0,0
  17. for i in range(len(str_list_2[0])):
  18.     for j in range(0, M):
  19.         if str_list_2[j][i] == 'A':
  20.             if i not in cnt_dict_2:
  21.                 cnt_dict_2[i] = 1
  22.             else:
  23.                 cnt_dict_2[i] += 1
  24.         else:
  25.             cnt_dict_2[i] = 0
  26. for key, value in cnt_dict_1.items():
  27.     if cnt_dict_2[key] + value == 0 or ((N - value) + (M - cnt_dict_2[key])) == 0 or (M - cnt_dict_2[key]) / ((N - value) + (M - cnt_dict_2[key])) == 0 :
  28.         print(-1, end=' ')
  29.     else:
  30.         frac_1 = cnt_dict_2[key] / (cnt_dict_2[key] + value)
  31.         frac_2 = (M - cnt_dict_2[key]) / ((N - value) + (M - cnt_dict_2[key]))
  32.         print(frac_1 / frac_2, end=' ')
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement