Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- N = int(input())
- str_list_1 = [input() for i in range(N)]
- M = int(input())
- str_list_2 = [input() for i in range(M)]
- cnt_dict_1 = {}
- cnt_dict_2 = {}
- for i in range(len(str_list_1[0])):
- for j in range(0, N):
- if str_list_1[j][i] == 'A':
- if i not in cnt_dict_1:
- cnt_dict_1[i] = 1
- else:
- cnt_dict_1[i] += 1
- else:
- cnt_dict_1[i] = 0
- i, j = 0,0
- for i in range(len(str_list_2[0])):
- for j in range(0, M):
- if str_list_2[j][i] == 'A':
- if i not in cnt_dict_2:
- cnt_dict_2[i] = 1
- else:
- cnt_dict_2[i] += 1
- else:
- cnt_dict_2[i] = 0
- for key, value in cnt_dict_1.items():
- 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 :
- print(-1, end=' ')
- else:
- frac_1 = cnt_dict_2[key] / (cnt_dict_2[key] + value)
- frac_2 = (M - cnt_dict_2[key]) / ((N - value) + (M - cnt_dict_2[key]))
- print(frac_1 / frac_2, end=' ')
Advertisement
Advertisement