結果

問題 No.2446 完全列
ユーザー hiro1729hiro1729
提出日時 2023-08-27 19:51:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 32 ms / 2,000 ms
コード長 937 bytes
コンパイル時間 80 ms
コンパイル使用メモリ 11,088 KB
実行使用メモリ 9,972 KB
最終ジャッジ日時 2023-08-27 19:51:47
合計ジャッジ時間 2,536 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
9,816 KB
testcase_01 AC 31 ms
9,720 KB
testcase_02 AC 32 ms
9,852 KB
testcase_03 AC 31 ms
9,856 KB
testcase_04 AC 31 ms
9,852 KB
testcase_05 AC 31 ms
9,704 KB
testcase_06 AC 31 ms
9,872 KB
testcase_07 AC 31 ms
9,708 KB
testcase_08 AC 32 ms
9,972 KB
testcase_09 AC 31 ms
9,808 KB
testcase_10 AC 31 ms
9,764 KB
testcase_11 AC 31 ms
9,676 KB
testcase_12 AC 32 ms
9,708 KB
testcase_13 AC 31 ms
9,764 KB
testcase_14 AC 32 ms
9,844 KB
testcase_15 AC 31 ms
9,752 KB
testcase_16 AC 31 ms
9,844 KB
testcase_17 AC 32 ms
9,924 KB
testcase_18 AC 31 ms
9,596 KB
testcase_19 AC 31 ms
9,764 KB
testcase_20 AC 32 ms
9,720 KB
testcase_21 AC 32 ms
9,648 KB
testcase_22 AC 31 ms
9,920 KB
testcase_23 AC 32 ms
9,676 KB
testcase_24 AC 32 ms
9,804 KB
testcase_25 AC 31 ms
9,776 KB
testcase_26 AC 31 ms
9,784 KB
testcase_27 AC 32 ms
9,808 KB
testcase_28 AC 32 ms
9,768 KB
testcase_29 AC 32 ms
9,796 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from fractions import Fraction
def rank(c):
	d = []
	for i in c:
		b = False
		if any(i):
			d.append(i)
	h = len(d)
	if h == 0:
		return 0
	w = len(d[0])
	for i in range(h):
		k = 0
		while k < w and d[i][k] == 0:
			k += 1
		if k == w:
			return i
		# d[i][k]はd[i]の中で一番要素が小さい0でない要素なのでこれをベースにする
		bs = d[i][k]
		for j in range(w):
			d[i][j] /= bs
		for j in range(i + 1, h):
			bs2 = d[j][k]
			if bs2 != 0:
				for l in range(k, w):
					d[j][l] -= d[i][l] * bs2
	return h
l, m, n = map(int, input().split())
a = [list(map(lambda x: Fraction(int(x), 1), input().split())) for _ in range(l)]
b = [list(map(lambda x: Fraction(int(x), 1), input().split())) for _ in range(m)]
# AB=Oか?
for i in range(l):
	for j in range(n):
		if sum(a[i][k] * b[k][j] for k in range(m)) != 0:
			exit(print("No"))
# m-rank(a) = rank(b)ならOK
print("Yes" if rank(a) + rank(b) == m else "No")
0