結果

問題 No.1136 Four Points Tour
ユーザー flippergoflippergo
提出日時 2020-12-24 14:01:38
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
TLE  
実行時間 -
コード長 488 bytes
コンパイル時間 342 ms
コンパイル使用メモリ 11,968 KB
実行使用メモリ 42,240 KB
最終ジャッジ日時 2023-10-21 15:40:43
合計ジャッジ時間 22,737 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 495 ms
42,240 KB
testcase_01 AC 493 ms
42,240 KB
testcase_02 AC 492 ms
42,240 KB
testcase_03 AC 493 ms
42,240 KB
testcase_04 AC 489 ms
42,240 KB
testcase_05 AC 496 ms
42,240 KB
testcase_06 AC 497 ms
42,240 KB
testcase_07 AC 1,930 ms
42,240 KB
testcase_08 AC 503 ms
42,240 KB
testcase_09 AC 496 ms
42,240 KB
testcase_10 TLE -
testcase_11 AC 513 ms
42,240 KB
testcase_12 AC 766 ms
42,240 KB
testcase_13 AC 500 ms
42,240 KB
testcase_14 AC 740 ms
42,240 KB
testcase_15 AC 517 ms
42,240 KB
testcase_16 AC 769 ms
42,240 KB
testcase_17 AC 823 ms
42,240 KB
testcase_18 TLE -
testcase_19 TLE -
testcase_20 -- -
testcase_21 -- -
01_Sample03_evil.txt -- -
04_Rnd_large_evil1.txt -- -
04_Rnd_large_evil2.txt -- -
04_Rnd_large_evil3.txt -- -
04_Rnd_large_evil4.txt -- -
04_Rnd_large_evil5.txt -- -
04_Rnd_large_evil6.txt -- -
04_Rnd_large_evil7.txt -- -
04_Rnd_large_evil8.txt -- -
04_Rnd_large_evil9.txt -- -
04_Rnd_large_evil10.txt -- -
05_Rnd_huge_evil1.txt -- -
05_Rnd_huge_evil2.txt -- -
05_Rnd_huge_evil3.txt -- -
05_Rnd_huge_evil4.txt -- -
05_Rnd_huge_evil5.txt -- -
05_Rnd_huge_evil6.txt -- -
05_Rnd_huge_evil7.txt -- -
99_evil_01.txt -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import numpy as np
p = 10**9+7
I = np.array([[1,0,0,0],[0,1,0,0],[0,0,1,0],[0,0,0,1]],dtype=np.int64)
def pow(A,n):
    if n==0:
        return I
    if n==1:
        return A
    if n%2==0:
        return (np.matmul(pow(A,n//2),pow(A,n//2)))%p
    else:
        return np.matmul(A,np.matmul(pow(A,(n-1)//2),pow(A,(n-1)//2))%p)%p
A = np.array([[0,1,1,1],[1,0,1,1],[1,1,0,1],[1,1,1,0]],dtype=np.int64)
N = int(input())
a = np.matmul(np.array([1,0,0,0],dtype=np.int64),pow(A,N))
print(a[0])
0