結果
問題 | No.2444 一次変換と体積 |
ユーザー | tassei903 |
提出日時 | 2023-08-25 23:13:21 |
言語 | PyPy3 (7.3.15) |
結果 |
WA
|
実行時間 | - |
コード長 | 2,159 bytes |
コンパイル時間 | 304 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 76,544 KB |
最終ジャッジ日時 | 2024-06-06 18:02:19 |
合計ジャッジ時間 | 2,721 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 42 ms
52,224 KB |
testcase_01 | AC | 41 ms
52,352 KB |
testcase_02 | AC | 40 ms
52,608 KB |
testcase_03 | WA | - |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | WA | - |
testcase_07 | AC | 39 ms
52,608 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | AC | 39 ms
52,608 KB |
testcase_11 | AC | 40 ms
52,480 KB |
testcase_12 | AC | 39 ms
52,608 KB |
testcase_13 | AC | 38 ms
52,608 KB |
testcase_14 | AC | 38 ms
52,736 KB |
testcase_15 | WA | - |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | WA | - |
testcase_19 | AC | 939 ms
76,544 KB |
ソースコード
import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### import sys input = lambda :sys.stdin.readline()[:-1] ni = lambda :int(input()) na = lambda :list(map(int,input().split())) yes = lambda :print("yes");Yes = lambda :print("Yes");YES = lambda : print("YES") no = lambda :print("no");No = lambda :print("No");NO = lambda : print("NO") ####################################################################### n, mod = na() a = [na() for i in range(3)] b = list(zip(*a)) z = a[0][0]*a[1][1]*a[2][2] + a[0][1]*a[1][2]*a[2][0] + a[0][2]*a[1][0]*a[2][1] - a[0][2]*a[1][1]*a[0][1] - a[0][1]*a[1][0]*a[2][2] - a[0][0]*a[1][2]*a[2][1] if z != 0: z = abs(z) print(pow(z, n, mod)) exit() def f(a, b): if a[0]*b[1] - a[1]*b[0] == 0 and a[0]*b[2] - a[2]*b[0] == 0: return 1 return 0 def det(a, b): return a[1]*b[2]-a[2]*b[1], a[2]*b[0]-a[0]*b[2], a[0]*b[1]-a[1]*b[0] def mat_mul(A,B): assert len(A[0]) == len(B) n = len(A) m = len(B[0]) p = len(A[0]) R = [[0 for j in range(m)]for i in range(n)] for i in range(n): for j in range(m): for k in range(p): R[i][j] += A[i][k]*B[k][j] % mod R[i][j] %= mod return R e = [[1,0,0],[0,1,0],[0,0,1]] for i in range(n): e = mat_mul(e, a) a = e b = list(zip(*a)) if a[0].count(0) + a[1].count(0) + a[2].count(0) == 9: print(0) elif f(b[0], b[1]) and f(b[0], b[2]): if (a[0][0] >= 0 and a[1][0] >= 0 and a[2][0] >= 0) or (a[0][0] <= 0 and a[1][0] <= 0 and a[2][0] <= 0): print(0) else: print("infty") else: if f(b[0], b[1])^1: z = det(b[0], b[1]) elif f(b[0], b[1])^1: z = det(b[0], b[2]) else: z = det(b[1], b[1]) if (z[0] > 0 and z[1] > 0 and z[2] > 0) or (z[0] < 0 and z[1] < 0 and z[2] < 0): print("infty") else: print(0)