結果

問題 No.1225 I hate I hate Matrix Construction
ユーザー tonnnura172tonnnura172
提出日時 2020-10-22 20:04:26
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 161 ms / 2,000 ms
コード長 1,252 bytes
コンパイル時間 593 ms
コンパイル使用メモリ 10,928 KB
実行使用メモリ 31,724 KB
最終ジャッジ日時 2023-09-28 14:48:47
合計ジャッジ時間 9,517 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
29,744 KB
testcase_01 AC 138 ms
29,856 KB
testcase_02 AC 139 ms
29,920 KB
testcase_03 AC 141 ms
29,712 KB
testcase_04 AC 160 ms
29,984 KB
testcase_05 AC 144 ms
29,852 KB
testcase_06 AC 147 ms
30,052 KB
testcase_07 AC 145 ms
30,004 KB
testcase_08 AC 146 ms
30,040 KB
testcase_09 AC 149 ms
30,104 KB
testcase_10 AC 151 ms
29,732 KB
testcase_11 AC 161 ms
29,892 KB
testcase_12 AC 148 ms
30,384 KB
testcase_13 AC 143 ms
29,976 KB
testcase_14 AC 144 ms
29,844 KB
testcase_15 AC 144 ms
30,676 KB
testcase_16 AC 147 ms
30,744 KB
testcase_17 AC 144 ms
30,828 KB
testcase_18 AC 146 ms
31,724 KB
testcase_19 AC 145 ms
30,048 KB
testcase_20 AC 143 ms
29,824 KB
testcase_21 AC 147 ms
30,456 KB
testcase_22 AC 145 ms
30,328 KB
testcase_23 AC 146 ms
30,232 KB
testcase_24 AC 144 ms
30,324 KB
testcase_25 AC 145 ms
30,580 KB
testcase_26 AC 144 ms
29,952 KB
testcase_27 AC 145 ms
29,712 KB
testcase_28 AC 145 ms
30,612 KB
testcase_29 AC 147 ms
30,016 KB
testcase_30 AC 148 ms
30,372 KB
testcase_31 AC 144 ms
31,096 KB
testcase_32 AC 155 ms
30,196 KB
testcase_33 AC 150 ms
30,324 KB
testcase_34 AC 144 ms
31,224 KB
testcase_35 AC 144 ms
31,272 KB
testcase_36 AC 145 ms
30,080 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd, log2
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul, add
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce, lru_cache
import numpy as np
def input(): return sys.stdin.buffer.readline()[:-1]
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = LIST()
T = LIST()

arr = np.zeros((N, N), dtype=np.int64)
# arr[:] = -1

for i in range(N):
	if S[i] == 0:
		arr[i, :] = 0
	elif S[i] == 2:
		arr[i, :] = 1

for i in range(N):
	if T[i] == 0:
		arr[:, i] = 0
	elif T[i] == 2:
		arr[:, i] = 1

# print(arr)
tate = 0
yoko = 0
for i in range(N):
	if S[i] == 1 and not any(arr[i, :]):
		yoko += 1
	if T[i] == 1 and not any(arr[:, i]):
		tate += 1

# print(tate, yoko)
print(arr.sum()+min(yoko, tate)+abs(yoko-tate))
0