結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー brthyyjpbrthyyjp
提出日時 2020-09-11 21:47:52
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,480 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 86,864 KB
実行使用メモリ 81,624 KB
最終ジャッジ日時 2023-08-27 13:51:18
合計ジャッジ時間 5,633 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
71,448 KB
testcase_01 AC 65 ms
71,236 KB
testcase_02 AC 67 ms
71,132 KB
testcase_03 RE -
testcase_04 AC 79 ms
76,220 KB
testcase_05 AC 75 ms
75,796 KB
testcase_06 AC 76 ms
76,476 KB
testcase_07 RE -
testcase_08 AC 77 ms
75,928 KB
testcase_09 AC 80 ms
76,276 KB
testcase_10 AC 77 ms
76,380 KB
testcase_11 AC 81 ms
76,604 KB
testcase_12 AC 81 ms
76,288 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 79 ms
76,128 KB
testcase_16 AC 77 ms
76,396 KB
testcase_17 AC 77 ms
76,128 KB
testcase_18 RE -
testcase_19 RE -
testcase_20 RE -
testcase_21 RE -
testcase_22 RE -
testcase_23 RE -
testcase_24 AC 77 ms
76,364 KB
testcase_25 AC 78 ms
76,340 KB
testcase_26 AC 77 ms
76,576 KB
testcase_27 AC 69 ms
71,116 KB
testcase_28 AC 85 ms
76,148 KB
testcase_29 AC 79 ms
76,520 KB
testcase_30 AC 82 ms
76,308 KB
testcase_31 AC 83 ms
76,404 KB
testcase_32 AC 87 ms
76,536 KB
testcase_33 AC 81 ms
76,360 KB
testcase_34 AC 88 ms
76,184 KB
testcase_35 AC 88 ms
76,424 KB
testcase_36 AC 81 ms
76,352 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
        else:
            for j in range(n):
                if j not in ds[0]:
                    if A[i][j] == 0:
                        A[i][j] = 1
                        break
    #ds[1].remove(i)

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 i in ds[1]:
            if i not in ds[0] and A[i][j] == 0:
                A[i][j] = 1
                ds[1].remove(i)
                break
        else:
            for i in range(n):
                if i not in ds[0]:
                    if A[i][j] == 0:
                        A[i][j] = 1
                        break
    #dt[1].remove(j)
#print(A)
ans = 0
for i in range(n):
    for j in range(n):
        ans += A[i][j]
print(ans)
0