結果
問題 | No.1136 Four Points Tour |
ユーザー | rlangevin |
提出日時 | 2023-01-09 21:16:52 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 52 ms / 2,000 ms |
コード長 | 655 bytes |
コンパイル時間 | 188 ms |
コンパイル使用メモリ | 82,584 KB |
実行使用メモリ | 62,960 KB |
最終ジャッジ日時 | 2024-05-10 02:34:37 |
合計ジャッジ時間 | 3,725 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 46 ms
61,812 KB |
testcase_01 | AC | 47 ms
61,412 KB |
testcase_02 | AC | 47 ms
61,960 KB |
testcase_03 | AC | 47 ms
62,644 KB |
testcase_04 | AC | 47 ms
62,304 KB |
testcase_05 | AC | 48 ms
61,488 KB |
testcase_06 | AC | 47 ms
62,024 KB |
testcase_07 | AC | 47 ms
61,460 KB |
testcase_08 | AC | 47 ms
62,208 KB |
testcase_09 | AC | 47 ms
62,228 KB |
testcase_10 | AC | 49 ms
61,220 KB |
testcase_11 | AC | 47 ms
61,952 KB |
testcase_12 | AC | 52 ms
61,616 KB |
testcase_13 | AC | 47 ms
62,960 KB |
testcase_14 | AC | 46 ms
62,352 KB |
testcase_15 | AC | 47 ms
62,200 KB |
testcase_16 | AC | 47 ms
62,812 KB |
testcase_17 | AC | 48 ms
61,992 KB |
testcase_18 | AC | 47 ms
61,812 KB |
testcase_19 | AC | 48 ms
62,144 KB |
testcase_20 | AC | 47 ms
62,040 KB |
testcase_21 | AC | 47 ms
61,832 KB |
01_Sample03_evil.txt | AC | 48 ms
62,932 KB |
04_Rnd_large_evil1.txt | AC | 47 ms
61,700 KB |
04_Rnd_large_evil2.txt | AC | 47 ms
62,264 KB |
04_Rnd_large_evil3.txt | AC | 47 ms
62,340 KB |
04_Rnd_large_evil4.txt | AC | 48 ms
61,968 KB |
04_Rnd_large_evil5.txt | AC | 47 ms
61,548 KB |
04_Rnd_large_evil6.txt | AC | 47 ms
62,268 KB |
04_Rnd_large_evil7.txt | AC | 48 ms
62,408 KB |
04_Rnd_large_evil8.txt | AC | 47 ms
62,200 KB |
04_Rnd_large_evil9.txt | AC | 47 ms
61,944 KB |
04_Rnd_large_evil10.txt | AC | 47 ms
62,596 KB |
05_Rnd_huge_evil1.txt | AC | 47 ms
62,144 KB |
05_Rnd_huge_evil2.txt | AC | 47 ms
61,812 KB |
05_Rnd_huge_evil3.txt | AC | 48 ms
62,564 KB |
05_Rnd_huge_evil4.txt | AC | 48 ms
62,396 KB |
05_Rnd_huge_evil5.txt | AC | 48 ms
62,160 KB |
05_Rnd_huge_evil6.txt | AC | 47 ms
62,252 KB |
05_Rnd_huge_evil7.txt | AC | 47 ms
62,084 KB |
99_evil_01.txt | AC | 47 ms
62,344 KB |
ソースコード
def Matprod(A, B, mod): N = len(A) temp = [[0] * N for i in range(N)] for i in range(N): for j in range(N): for k in range(N): temp[i][j] += A[i][k] * B[k][j] temp[i][j] %= mod return temp def Matpow(A, M, mod): N = len(A) Mat = [[0] * N for i in range(N)] for i in range(N): Mat[i][i] = 1 for i in range(64): if (M >> i) & 1: Mat = Matprod(Mat, A, mod) A = Matprod(A, A, mod) return Mat N = int(input()) M = [[0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]] mod = 10 ** 9 + 7 print(Matpow(M, N, mod)[0][0]%mod)