結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー brthyyjpbrthyyjp
提出日時 2020-09-11 21:42:02
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,018 bytes
コンパイル時間 274 ms
コンパイル使用メモリ 87,204 KB
実行使用メモリ 81,968 KB
最終ジャッジ日時 2023-08-27 13:06:06
合計ジャッジ時間 5,796 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,420 KB
testcase_01 AC 68 ms
71,444 KB
testcase_02 AC 68 ms
71,312 KB
testcase_03 RE -
testcase_04 AC 82 ms
76,640 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 RE -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 82 ms
76,840 KB
testcase_11 AC 83 ms
76,516 KB
testcase_12 WA -
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 83 ms
76,620 KB
testcase_16 AC 83 ms
76,472 KB
testcase_17 AC 83 ms
76,784 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 82 ms
76,720 KB
testcase_25 AC 82 ms
76,616 KB
testcase_26 AC 79 ms
76,516 KB
testcase_27 AC 68 ms
71,560 KB
testcase_28 AC 83 ms
76,276 KB
testcase_29 AC 82 ms
76,488 KB
testcase_30 AC 85 ms
76,372 KB
testcase_31 AC 87 ms
76,600 KB
testcase_32 AC 88 ms
76,444 KB
testcase_33 AC 81 ms
76,624 KB
testcase_34 AC 91 ms
76,668 KB
testcase_35 AC 91 ms
76,596 KB
testcase_36 AC 86 ms
76,656 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = list(map(int, input().split()))
T = list(map(int, input().split()))

ds = [set() for i in range(3)]
dt = [set() for i in range(3)]

for i, s in enumerate(S):
    ds[s].add(i)
for i, t in enumerate(T):
    dt[t].add(i)

A = [[0]*n for _ in range(n)]
for i in ds[2]:
    for j in range(n):
        A[i][j] = 1

for j in dt[2]:
    for i in range(n):
        A[i][j] = 1

for i in ds[1]:
    cnt = 0
    for j in range(n):
        if A[i][j] == 1:
            cnt += 1
    if cnt == 0:
        for j in range(n):
            if j not in dt[0] and j in dt[1]:
                A[i][j] = 1
                dt[1].remove(j)
                break

for j in dt[1]:
    cnt = 0
    for i in range(n):
        if A[i][j] == 1:
            cnt += 1
    if cnt == 0:
        for i in range(n):
            if i not in ds[0] and ds[1]:
                A[i][j] = 1
                ds[1].remove(i)
                break
#print(A)
ans = 0
for i in range(n):
    for j in range(n):
        ans += A[i][j]
print(ans)
0