結果

問題 No.2255 Determinant Sum
ユーザー shobonvipshobonvip
提出日時 2023-03-12 01:33:43
言語 PyPy3
(7.3.15)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 749 bytes
コンパイル時間 466 ms
コンパイル使用メモリ 81,528 KB
実行使用メモリ 77,212 KB
最終ジャッジ日時 2023-10-18 20:35:55
合計ジャッジ時間 3,177 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,380 KB
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 AC 97 ms
76,108 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 92 ms
76,364 KB
testcase_11 AC 78 ms
75,800 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 86 ms
76,488 KB
testcase_19 AC 82 ms
75,912 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

T = int(input())
for _ in range(T):
	n, p = map(int,input().split())
	a = [list(map(int,input().split())) for i in range(n)]
	if p > 2:
		print(0)
		continue
	# p = 2
	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:
		print(0)
		continue
	
	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:
		print(1)
	else:
		print(0)
0