結果
| 問題 | No.1225 I hate I hate Matrix Construction | 
| コンテスト | |
| ユーザー |  neterukun | 
| 提出日時 | 2020-09-11 22:12:28 | 
| 言語 | PyPy3 (7.3.15) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 56 ms / 2,000 ms | 
| コード長 | 733 bytes | 
| コンパイル時間 | 249 ms | 
| コンパイル使用メモリ | 82,272 KB | 
| 実行使用メモリ | 63,872 KB | 
| 最終ジャッジ日時 | 2024-12-27 14:55:14 | 
| 合計ジャッジ時間 | 3,086 ms | 
| ジャッジサーバーID (参考情報) | judge1 / judge4 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 35 | 
ソースコード
n = int(input())
s = list(map(int, input().split()))
t = list(map(int, input().split()))
a = [[-1] * n for i in range(n)]
for i in range(n):
    if s[i] == 0:
        for j in range(n):
            a[i][j] = 0
    if s[i] == 2:
        for j in range(n):
            a[i][j] = 1
    if t[i] == 0:
        for j in range(n):
            a[j][i] = 0
    if t[i] == 2:
        for j in range(n):
            a[j][i] = 1
cnt1 = 0
for i in range(n):
    for j in range(n):
        if a[i][j] == 1:
            cnt1 += 1
if 2 in s and 2 in t:
    print(cnt1)
elif 0 in s and 0 in t:
    print(max(s.count(1), t.count(1)))
elif 2 in s or 2 in t:
    print(cnt1 + min(s.count(1), t.count(1)))
else:
    print(max(s.count(1), t.count(1)))
            
            
            
        