結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー tonyu0tonyu0
提出日時 2020-09-11 22:11:11
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 686 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,192 KB
実行使用メモリ 79,176 KB
最終ジャッジ日時 2023-08-27 14:53:33
合計ジャッジ時間 13,305 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 67 ms
71,072 KB
testcase_02 AC 68 ms
71,028 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 AC 78 ms
75,772 KB
testcase_16 AC 81 ms
75,748 KB
testcase_17 AC 77 ms
76,180 KB
testcase_18 AC 612 ms
76,280 KB
testcase_19 AC 85 ms
76,016 KB
testcase_20 AC 194 ms
75,896 KB
testcase_21 AC 428 ms
76,048 KB
testcase_22 AC 206 ms
75,864 KB
testcase_23 AC 241 ms
76,368 KB
testcase_24 AC 75 ms
75,964 KB
testcase_25 AC 79 ms
75,840 KB
testcase_26 AC 76 ms
75,764 KB
testcase_27 WA -
testcase_28 AC 121 ms
76,484 KB
testcase_29 AC 285 ms
75,996 KB
testcase_30 AC 438 ms
75,948 KB
testcase_31 AC 491 ms
76,044 KB
testcase_32 AC 1,337 ms
78,224 KB
testcase_33 AC 206 ms
76,240 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
s = list(map(int, input().split()))  # 行情報
t = list(map(int, input().split()))  # 列情報
u = [[False] * n for _ in range(n)]

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

for i in range(n):
    for j in range(n):
        if s[i] == 1 and t[j] == 1:
            ok1 = False
            ok2 = False
            for k in range(n):
                ok1 |= u[i][k]
                ok2 |= u[k][j]
            if not (ok1 and ok2):
                ans += 1
                u[i][j] = True
print(ans)
0