結果
問題 | No.1136 Four Points Tour |
ユーザー | mkawa2 |
提出日時 | 2021-06-22 13:20:38 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 31 ms / 2,000 ms |
コード長 | 1,318 bytes |
コンパイル時間 | 337 ms |
コンパイル使用メモリ | 12,800 KB |
実行使用メモリ | 11,008 KB |
最終ジャッジ日時 | 2024-06-23 09:49:44 |
合計ジャッジ時間 | 2,865 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 27 ms
11,008 KB |
testcase_01 | AC | 29 ms
10,752 KB |
testcase_02 | AC | 28 ms
10,752 KB |
testcase_03 | AC | 29 ms
10,880 KB |
testcase_04 | AC | 28 ms
10,752 KB |
testcase_05 | AC | 27 ms
10,752 KB |
testcase_06 | AC | 27 ms
10,752 KB |
testcase_07 | AC | 29 ms
10,752 KB |
testcase_08 | AC | 28 ms
10,880 KB |
testcase_09 | AC | 31 ms
10,880 KB |
testcase_10 | AC | 28 ms
10,752 KB |
testcase_11 | AC | 31 ms
10,880 KB |
testcase_12 | AC | 27 ms
10,752 KB |
testcase_13 | AC | 27 ms
10,880 KB |
testcase_14 | AC | 28 ms
10,880 KB |
testcase_15 | AC | 28 ms
10,880 KB |
testcase_16 | AC | 29 ms
10,752 KB |
testcase_17 | AC | 28 ms
10,880 KB |
testcase_18 | AC | 28 ms
10,752 KB |
testcase_19 | AC | 28 ms
10,880 KB |
testcase_20 | AC | 27 ms
10,752 KB |
testcase_21 | AC | 28 ms
10,880 KB |
01_Sample03_evil.txt | AC | 28 ms
10,880 KB |
04_Rnd_large_evil1.txt | AC | 27 ms
10,880 KB |
04_Rnd_large_evil2.txt | AC | 28 ms
10,752 KB |
04_Rnd_large_evil3.txt | AC | 28 ms
10,880 KB |
04_Rnd_large_evil4.txt | AC | 28 ms
10,752 KB |
04_Rnd_large_evil5.txt | AC | 28 ms
10,880 KB |
04_Rnd_large_evil6.txt | AC | 27 ms
10,880 KB |
04_Rnd_large_evil7.txt | AC | 28 ms
10,880 KB |
04_Rnd_large_evil8.txt | AC | 29 ms
10,752 KB |
04_Rnd_large_evil9.txt | AC | 28 ms
10,880 KB |
04_Rnd_large_evil10.txt | AC | 29 ms
10,880 KB |
05_Rnd_huge_evil1.txt | AC | 29 ms
10,880 KB |
05_Rnd_huge_evil2.txt | AC | 28 ms
10,880 KB |
05_Rnd_huge_evil3.txt | AC | 27 ms
10,752 KB |
05_Rnd_huge_evil4.txt | AC | 29 ms
10,880 KB |
05_Rnd_huge_evil5.txt | AC | 29 ms
10,880 KB |
05_Rnd_huge_evil6.txt | AC | 28 ms
10,880 KB |
05_Rnd_huge_evil7.txt | AC | 29 ms
10,752 KB |
99_evil_01.txt | AC | 29 ms
10,880 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") def II(): return int(sys.stdin.buffer.readline()) def LI(): return list(map(int, sys.stdin.buffer.readline().split())) def LI1(): return list(map(int1, sys.stdin.buffer.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def BI(): return sys.stdin.buffer.readline().rstrip() def SI(): return sys.stdin.buffer.readline().rstrip().decode() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = 10**16 # md = 998244353 md = 10**9+7 def dot(aa, bb): h = len(aa) w = len(bb[0]) res = [[0]*w for _ in range(h)] for i, row in enumerate(aa): for j, col in enumerate(zip(*bb)): v = 0 # for a, b in zip(row, col): v += a*b for a, b in zip(row, col): v = (v+a*b)%md res[i][j] = v return res def matpow(mat, e): n = len(mat) res = [[1 if i == j else 0 for j in range(n)] for i in range(n)] while e: if e & 1: res = dot(res, mat) mat = dot(mat, mat) e >>= 1 return res n = II() cc = [[0, 3], [1, 2]] cc = matpow(cc, n) print(cc[0][0])