結果
問題 | No.2405 Minimal Matrix Decomposition |
ユーザー | chineristAC |
提出日時 | 2023-08-04 22:26:37 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 462 ms / 2,000 ms |
コード長 | 1,404 bytes |
コンパイル時間 | 238 ms |
コンパイル使用メモリ | 82,244 KB |
実行使用メモリ | 81,792 KB |
最終ジャッジ日時 | 2024-10-14 20:26:01 |
合計ジャッジ時間 | 8,924 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 38 ms
52,096 KB |
testcase_01 | AC | 36 ms
52,096 KB |
testcase_02 | AC | 37 ms
52,224 KB |
testcase_03 | AC | 36 ms
52,352 KB |
testcase_04 | AC | 77 ms
76,800 KB |
testcase_05 | AC | 462 ms
81,792 KB |
testcase_06 | AC | 38 ms
52,224 KB |
testcase_07 | AC | 38 ms
52,224 KB |
testcase_08 | AC | 38 ms
52,224 KB |
testcase_09 | AC | 38 ms
52,096 KB |
testcase_10 | AC | 238 ms
79,232 KB |
testcase_11 | AC | 279 ms
79,872 KB |
testcase_12 | AC | 65 ms
68,352 KB |
testcase_13 | AC | 110 ms
77,056 KB |
testcase_14 | AC | 120 ms
77,824 KB |
testcase_15 | AC | 84 ms
76,672 KB |
testcase_16 | AC | 74 ms
72,832 KB |
testcase_17 | AC | 149 ms
78,208 KB |
testcase_18 | AC | 124 ms
77,440 KB |
testcase_19 | AC | 119 ms
77,568 KB |
testcase_20 | AC | 63 ms
66,560 KB |
testcase_21 | AC | 78 ms
74,496 KB |
testcase_22 | AC | 222 ms
78,848 KB |
testcase_23 | AC | 63 ms
65,664 KB |
testcase_24 | AC | 59 ms
66,176 KB |
testcase_25 | AC | 78 ms
74,496 KB |
testcase_26 | AC | 176 ms
78,464 KB |
testcase_27 | AC | 104 ms
77,568 KB |
testcase_28 | AC | 156 ms
78,592 KB |
testcase_29 | AC | 98 ms
77,440 KB |
testcase_30 | AC | 200 ms
78,848 KB |
testcase_31 | AC | 114 ms
77,184 KB |
testcase_32 | AC | 70 ms
69,760 KB |
testcase_33 | AC | 174 ms
78,464 KB |
testcase_34 | AC | 98 ms
76,800 KB |
testcase_35 | AC | 45 ms
59,264 KB |
testcase_36 | AC | 108 ms
77,184 KB |
testcase_37 | AC | 129 ms
77,312 KB |
testcase_38 | AC | 127 ms
77,952 KB |
testcase_39 | AC | 173 ms
78,464 KB |
testcase_40 | AC | 110 ms
77,184 KB |
testcase_41 | AC | 67 ms
69,120 KB |
testcase_42 | AC | 201 ms
78,592 KB |
testcase_43 | AC | 95 ms
77,440 KB |
testcase_44 | AC | 104 ms
77,184 KB |
testcase_45 | AC | 79 ms
73,088 KB |
testcase_46 | AC | 97 ms
77,184 KB |
testcase_47 | AC | 104 ms
77,184 KB |
testcase_48 | AC | 77 ms
72,960 KB |
testcase_49 | AC | 59 ms
66,816 KB |
ソースコード
import sys input = lambda :sys.stdin.readline().rstrip() mod = int(input()) N,M = map(int,input().split()) A = [list(map(int,input().split())) for i in range(N)] original = [[A[i][j] for j in range(M)] for i in range(N)] rank = 0 B = [[] for i in range(N)] C = [] for j in range(M): pivot = -1 for i in range(j,N): if A[i][j]!=0: pivot = i break if pivot == -1: continue rank += 1 C.append([A[pivot][j] for j in range(M)]) inv = pow(A[pivot][j],mod-2,mod) for i in range(N): if i == pivot: continue t = A[i][j] * inv % mod B[i].append(t) for k in range(j,M): A[i][k] -= A[pivot][k] * t % mod A[i][k] %= mod #print(A[i]) B[pivot].append(1) for j in range(M): A[pivot][j] = 0 #print() if rank == 0: if N*M >= N+M: print(2) print(N,1) for i in range(N): print(0) print(1,M) print(*[0]*M) exit() else: print(1) print(N,M) for i in range(N): print(*[0]*M) exit() if N*M <= rank * (N+M): print(1) print(N,M) for i in range(N): print(*original[i]) else: print(2) print(N,rank) for i in range(N): print(*B[i]) print(rank,M) for i in range(rank): print(*C[i])