結果

問題 No.2255 Determinant Sum
ユーザー shobonvipshobonvip
提出日時 2023-03-12 01:36:40
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 764 bytes
コンパイル時間 155 ms
コンパイル使用メモリ 81,628 KB
実行使用メモリ 76,616 KB
最終ジャッジ日時 2023-10-18 20:35:58
合計ジャッジ時間 2,969 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
53,444 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 94 ms
76,140 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 91 ms
76,388 KB
testcase_11 AC 76 ms
75,840 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 84 ms
75,924 KB
testcase_19 AC 83 ms
75,924 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

def solve(n, p, a):
	if p > 2:
		return 0
	
	x = [0] * n
	y = [0] * n
	for i in range(n):
		for j in range(n):
			if a[i][j] == -1:
				x[i] += 1
				y[j] += 1
	
	mode = 1
	for i in range(n):
		if x[i] > 1 or y[i] > 1:
			mode = 0
			break

	if mode == 0:
		return 0

	bx = []
	by = []
	for i in range(n):
		if x[i] == 0:
			bx.append(x[i])
		if y[i] == 0:
			by.append(y[i])

	m = len(bx)
	b = [0] * m
	for i in range(m):
		for j in range(m):
			b[i] ^= a[bx[i]][by[j]] << j
	
	base = []
	for v in b:
		for e in base:
			v = min(v, v^e)
		if v > 0: base.append(v)
	
	if len(base) == m:
		return 1
	else:
		return 0

T = int(input())
for _ in range(T):
	n, p = map(int,input().split())
	a = [list(map(int,input().split())) for i in range(n)]
	print(solve(n, p, a))
0