結果
問題 | No.1136 Four Points Tour |
ユーザー | tcltk |
提出日時 | 2021-01-16 09:09:27 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 544 ms / 2,000 ms |
コード長 | 1,307 bytes |
コンパイル時間 | 238 ms |
コンパイル使用メモリ | 12,416 KB |
実行使用メモリ | 44,924 KB |
最終ジャッジ日時 | 2024-11-27 08:46:24 |
合計ジャッジ時間 | 25,425 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 523 ms
44,808 KB |
testcase_01 | AC | 531 ms
44,292 KB |
testcase_02 | AC | 527 ms
44,544 KB |
testcase_03 | AC | 529 ms
44,680 KB |
testcase_04 | AC | 537 ms
44,616 KB |
testcase_05 | AC | 544 ms
44,292 KB |
testcase_06 | AC | 527 ms
44,484 KB |
testcase_07 | AC | 528 ms
44,288 KB |
testcase_08 | AC | 532 ms
44,540 KB |
testcase_09 | AC | 528 ms
44,296 KB |
testcase_10 | AC | 496 ms
44,804 KB |
testcase_11 | AC | 505 ms
44,424 KB |
testcase_12 | AC | 504 ms
44,420 KB |
testcase_13 | AC | 509 ms
44,804 KB |
testcase_14 | AC | 500 ms
44,420 KB |
testcase_15 | AC | 507 ms
44,924 KB |
testcase_16 | AC | 503 ms
44,408 KB |
testcase_17 | AC | 503 ms
44,804 KB |
testcase_18 | AC | 506 ms
44,804 KB |
testcase_19 | AC | 496 ms
44,552 KB |
testcase_20 | AC | 501 ms
44,796 KB |
testcase_21 | AC | 493 ms
44,288 KB |
01_Sample03_evil.txt | AC | 495 ms
44,416 KB |
04_Rnd_large_evil1.txt | AC | 495 ms
44,420 KB |
04_Rnd_large_evil2.txt | AC | 497 ms
44,672 KB |
04_Rnd_large_evil3.txt | AC | 503 ms
44,804 KB |
04_Rnd_large_evil4.txt | AC | 489 ms
44,800 KB |
04_Rnd_large_evil5.txt | AC | 496 ms
44,720 KB |
04_Rnd_large_evil6.txt | AC | 494 ms
44,676 KB |
04_Rnd_large_evil7.txt | AC | 498 ms
44,804 KB |
04_Rnd_large_evil8.txt | AC | 491 ms
44,904 KB |
04_Rnd_large_evil9.txt | AC | 490 ms
44,800 KB |
04_Rnd_large_evil10.txt | AC | 493 ms
44,292 KB |
05_Rnd_huge_evil1.txt | AC | 497 ms
44,328 KB |
05_Rnd_huge_evil2.txt | AC | 461 ms
44,284 KB |
05_Rnd_huge_evil3.txt | AC | 462 ms
44,292 KB |
05_Rnd_huge_evil4.txt | AC | 472 ms
44,808 KB |
05_Rnd_huge_evil5.txt | AC | 477 ms
44,420 KB |
05_Rnd_huge_evil6.txt | AC | 478 ms
44,816 KB |
05_Rnd_huge_evil7.txt | AC | 464 ms
44,804 KB |
99_evil_01.txt | AC | 463 ms
44,932 KB |
ソースコード
#region Header #!/usr/bin/env python3 # from typing import * import sys import io import math import collections import decimal import itertools from queue import PriorityQueue import bisect import heapq import numpy as np def input(): return sys.stdin.readline()[:-1] sys.setrecursionlimit(1000000) #endregion # _INPUT = """334 # """ # sys.stdin = io.StringIO(_INPUT) MOD = 1000000007 def main(): N = int(input()) # dp = [[0, 0, 0, 0] for _ in range(N+1)] # dp[0][0] = 1 # for i in range(1, N+1): # dp[i][0] = (dp[i-1][1] + dp[i-1][2] + dp[i-1][3]) % MOD # dp[i][1] = (dp[i-1][0] + dp[i-1][2] + dp[i-1][3]) % MOD # dp[i][2] = (dp[i-1][0] + dp[i-1][1] + dp[i-1][3]) % MOD # dp[i][3] = (dp[i-1][0] + dp[i-1][1] + dp[i-1][2]) % MOD # print(dp[N][0]) A = np.matrix([ [0, 1, 1, 1], [1, 0, 1, 1], [1, 1, 0, 1], [1, 1, 1, 0]], dtype=object) # A_N = np.linalg.matrix_power(A, N) M = A R = np.identity(4, dtype=object) while N > 0: if N & 1 > 0: R = (R * M) % MOD M = (M * M) % MOD N >>= 1 v = R * np.array([[1], [0], [0], [0]]) print(v.item(0, 0) % MOD) if __name__ == '__main__': main()