結果
問題 | No.2405 Minimal Matrix Decomposition |
ユーザー | gr1msl3y |
提出日時 | 2023-08-17 17:44:07 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,692 bytes |
コンパイル時間 | 868 ms |
コンパイル使用メモリ | 82,816 KB |
実行使用メモリ | 79,360 KB |
最終ジャッジ日時 | 2024-05-05 00:27:07 |
合計ジャッジ時間 | 10,322 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,736 KB |
testcase_01 | AC | 41 ms
52,224 KB |
testcase_02 | AC | 38 ms
52,224 KB |
testcase_03 | AC | 38 ms
52,224 KB |
testcase_04 | AC | 80 ms
77,184 KB |
testcase_05 | AC | 774 ms
79,360 KB |
testcase_06 | AC | 38 ms
52,480 KB |
testcase_07 | AC | 37 ms
52,224 KB |
testcase_08 | AC | 36 ms
52,224 KB |
testcase_09 | AC | 37 ms
52,608 KB |
testcase_10 | AC | 280 ms
78,464 KB |
testcase_11 | AC | 337 ms
79,232 KB |
testcase_12 | AC | 66 ms
68,608 KB |
testcase_13 | AC | 107 ms
77,184 KB |
testcase_14 | AC | 131 ms
77,312 KB |
testcase_15 | WA | - |
testcase_16 | AC | 73 ms
72,832 KB |
testcase_17 | AC | 167 ms
77,824 KB |
testcase_18 | AC | 142 ms
77,184 KB |
testcase_19 | AC | 138 ms
77,312 KB |
testcase_20 | AC | 61 ms
66,688 KB |
testcase_21 | WA | - |
testcase_22 | AC | 271 ms
78,464 KB |
testcase_23 | AC | 61 ms
66,688 KB |
testcase_24 | AC | 60 ms
66,688 KB |
testcase_25 | AC | 77 ms
73,600 KB |
testcase_26 | AC | 219 ms
77,952 KB |
testcase_27 | AC | 111 ms
77,440 KB |
testcase_28 | AC | 217 ms
77,696 KB |
testcase_29 | AC | 99 ms
77,184 KB |
testcase_30 | AC | 245 ms
78,080 KB |
testcase_31 | AC | 127 ms
77,056 KB |
testcase_32 | AC | 65 ms
69,632 KB |
testcase_33 | AC | 200 ms
77,824 KB |
testcase_34 | AC | 90 ms
76,928 KB |
testcase_35 | AC | 45 ms
59,136 KB |
testcase_36 | AC | 109 ms
77,184 KB |
testcase_37 | AC | 139 ms
77,568 KB |
testcase_38 | AC | 160 ms
77,568 KB |
testcase_39 | AC | 260 ms
77,952 KB |
testcase_40 | AC | 117 ms
77,696 KB |
testcase_41 | AC | 69 ms
70,272 KB |
testcase_42 | AC | 232 ms
78,336 KB |
testcase_43 | AC | 97 ms
77,312 KB |
testcase_44 | AC | 106 ms
76,928 KB |
testcase_45 | AC | 77 ms
72,704 KB |
testcase_46 | AC | 103 ms
76,928 KB |
testcase_47 | AC | 116 ms
77,184 KB |
testcase_48 | AC | 80 ms
73,472 KB |
testcase_49 | AC | 59 ms
66,944 KB |
ソースコード
def prod(A, B, MOD): n = len(A) m = len(B[0]) res = [[0]*m for _ in range(n)] for i in range(n): for j in range(m): for k in range(len(B)): res[i][j] += A[i][k]*B[k][j] % MOD res[i][j] %= MOD return res P = int(input()) N, M = map(int, input().split()) A = [list(map(int, input().split())) for _ in range(N)] if A == [[0]*M for _ in range(N)]: if min(N, M) == 1: print(1) print(N, M) for _ in range(N): print(*[0]*M) else: print(2) print(N, 1) for _ in range(N): print(0) print(1, M) print(*[0]*M) exit() B = [a[:] for a in A] for r in range(N): for i in range(r, N): flag = 0 for p in range(M): if B[i][p] != 0: flag = 1 break if flag: break else: break B[r], B[i] = B[i], B[r] inv = pow(B[r][p], P-2, P) for j in range(M): B[r][j] = B[r][j]*inv % P for i in range(N): if i == r: continue v = B[i][p] for j in range(M): B[i][j] -= v*B[r][j] % P B[i][j] %= P else: r = N r = min(r, M) if r*(N+M) >= N*M: print(1) print(N, M) for a in A: print(*a) exit() plist = [] p = 0 for i in range(N): while p < M: if B[i][p] == 1: break p += 1 else: break plist.append(p) p += 1 res0 = [[a[ind] for ind in plist] for a in A] res1 = B[:r] print(2) print(N, r) for res in res0: print(*res) print(r, M) for res in res1: print(*res) # print(prod(res0,res1,P))