結果
問題 | No.1136 Four Points Tour |
ユーザー | roaris |
提出日時 | 2020-07-27 22:46:47 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 47 ms / 2,000 ms |
コード長 | 699 bytes |
コンパイル時間 | 126 ms |
コンパイル使用メモリ | 82,388 KB |
実行使用メモリ | 60,672 KB |
最終ジャッジ日時 | 2024-06-28 20:19:05 |
合計ジャッジ時間 | 2,769 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 36 ms
52,224 KB |
testcase_01 | AC | 40 ms
52,096 KB |
testcase_02 | AC | 39 ms
52,352 KB |
testcase_03 | AC | 34 ms
52,608 KB |
testcase_04 | AC | 35 ms
52,096 KB |
testcase_05 | AC | 36 ms
52,352 KB |
testcase_06 | AC | 34 ms
52,736 KB |
testcase_07 | AC | 41 ms
59,904 KB |
testcase_08 | AC | 34 ms
52,480 KB |
testcase_09 | AC | 37 ms
57,088 KB |
testcase_10 | AC | 44 ms
60,672 KB |
testcase_11 | AC | 41 ms
59,264 KB |
testcase_12 | AC | 47 ms
60,160 KB |
testcase_13 | AC | 35 ms
52,224 KB |
testcase_14 | AC | 37 ms
60,160 KB |
testcase_15 | AC | 37 ms
59,648 KB |
testcase_16 | AC | 38 ms
60,160 KB |
testcase_17 | AC | 38 ms
60,032 KB |
testcase_18 | AC | 40 ms
60,160 KB |
testcase_19 | AC | 41 ms
59,904 KB |
testcase_20 | AC | 42 ms
59,904 KB |
testcase_21 | AC | 43 ms
60,288 KB |
01_Sample03_evil.txt | AC | 48 ms
61,440 KB |
04_Rnd_large_evil1.txt | AC | 46 ms
60,800 KB |
04_Rnd_large_evil2.txt | AC | 45 ms
61,056 KB |
04_Rnd_large_evil3.txt | AC | 41 ms
61,056 KB |
04_Rnd_large_evil4.txt | AC | 43 ms
60,672 KB |
04_Rnd_large_evil5.txt | AC | 42 ms
60,544 KB |
04_Rnd_large_evil6.txt | AC | 43 ms
61,056 KB |
04_Rnd_large_evil7.txt | AC | 43 ms
61,248 KB |
04_Rnd_large_evil8.txt | AC | 44 ms
60,672 KB |
04_Rnd_large_evil9.txt | AC | 43 ms
60,928 KB |
04_Rnd_large_evil10.txt | AC | 41 ms
61,184 KB |
05_Rnd_huge_evil1.txt | AC | 40 ms
60,928 KB |
05_Rnd_huge_evil2.txt | AC | 39 ms
60,800 KB |
05_Rnd_huge_evil3.txt | AC | 40 ms
61,056 KB |
05_Rnd_huge_evil4.txt | AC | 41 ms
60,928 KB |
05_Rnd_huge_evil5.txt | AC | 39 ms
60,928 KB |
05_Rnd_huge_evil6.txt | AC | 41 ms
61,056 KB |
05_Rnd_huge_evil7.txt | AC | 43 ms
61,440 KB |
99_evil_01.txt | AC | 41 ms
60,672 KB |
ソースコード
def mat_mul(A, B): C = [[0]*len(B[0]) for _ in range(len(A))] for i in range(len(A)): for j in range(len(B[0])): for k in range(len(A[0])): C[i][j] += A[i][k]*B[k][j] C[i][j] %= MOD return C def mat_pow(A, n): res = [[0]*len(A) for _ in range(len(A))] for i in range(len(A)): res[i][i] = 1 while n>0: if n&1: res = mat_mul(res, A) n >>= 1 A = mat_mul(A, A) return res N = int(input()) MOD = 10**9+7 A = [[1]*4 for _ in range(4)] for i in range(4): A[i][i] = 0 x = [[1], [0], [0], [0]] res = mat_mul(mat_pow(A, N), x) print(res[0][0])