結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー tonyu0tonyu0
提出日時 2020-09-11 22:46:10
言語 PyPy3
(7.3.13)
結果
AC  
実行時間 100 ms / 2,000 ms
コード長 861 bytes
コンパイル時間 487 ms
コンパイル使用メモリ 86,936 KB
実行使用メモリ 76,580 KB
最終ジャッジ日時 2023-08-27 15:48:42
合計ジャッジ時間 5,151 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,276 KB
testcase_01 AC 76 ms
71,260 KB
testcase_02 AC 78 ms
71,300 KB
testcase_03 AC 79 ms
75,420 KB
testcase_04 AC 89 ms
76,192 KB
testcase_05 AC 84 ms
75,552 KB
testcase_06 AC 89 ms
76,140 KB
testcase_07 AC 84 ms
75,780 KB
testcase_08 AC 87 ms
75,752 KB
testcase_09 AC 88 ms
76,256 KB
testcase_10 AC 84 ms
76,208 KB
testcase_11 AC 88 ms
76,228 KB
testcase_12 AC 88 ms
75,996 KB
testcase_13 AC 86 ms
75,760 KB
testcase_14 AC 81 ms
75,660 KB
testcase_15 AC 87 ms
76,308 KB
testcase_16 AC 87 ms
76,352 KB
testcase_17 AC 88 ms
76,260 KB
testcase_18 AC 89 ms
76,324 KB
testcase_19 AC 89 ms
76,292 KB
testcase_20 AC 85 ms
76,128 KB
testcase_21 AC 87 ms
76,416 KB
testcase_22 AC 88 ms
76,228 KB
testcase_23 AC 86 ms
76,216 KB
testcase_24 AC 84 ms
76,492 KB
testcase_25 AC 87 ms
76,140 KB
testcase_26 AC 84 ms
76,228 KB
testcase_27 AC 76 ms
71,260 KB
testcase_28 AC 87 ms
76,280 KB
testcase_29 AC 87 ms
76,368 KB
testcase_30 AC 87 ms
76,140 KB
testcase_31 AC 91 ms
76,148 KB
testcase_32 AC 87 ms
76,508 KB
testcase_33 AC 84 ms
76,316 KB
testcase_34 AC 94 ms
76,200 KB
testcase_35 AC 100 ms
76,580 KB
testcase_36 AC 91 ms
76,464 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = list(map(int, input().split()))  # 行情報
t = list(map(int, input().split()))  # 列情報

row = [0] * n
col = [0] * n

u = [[False] * n for _ in range(n)]

ans = 0
for i in range(n):
    if s[i] == 2:
        for j in range(n):
            if not u[i][j]:
                ans += 1
                col[j] += 1
                u[i][j] = True
    if t[i] == 2:
        for j in range(n):
            if not u[j][i]:
                ans += 1
                row[j] += 1
                u[j][i] = True

for i in range(n):
    for j in range(n):
        if s[i] == 1 and t[j] == 1:
            if row[i] == 0 and col[j] == 0:
                ans += 1
                row[i] += 1
                col[j] += 1

for i in range(n):
    if s[i] == 1 and row[i] == 0:
        ans += 1
    if t[i] == 1 and col[i] == 0:
        ans += 1

print(ans)
0