結果

問題 No.801 エレベーター
ユーザー takakintakakin
提出日時 2020-03-25 00:03:23
言語 PyPy3
(7.3.13)
結果
TLE  
実行時間 -
コード長 836 bytes
コンパイル時間 426 ms
コンパイル使用メモリ 87,124 KB
実行使用メモリ 88,524 KB
最終ジャッジ日時 2023-08-30 09:06:11
合計ジャッジ時間 4,782 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
75,992 KB
testcase_01 AC 75 ms
71,488 KB
testcase_02 AC 84 ms
76,300 KB
testcase_03 TLE -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
input=lambda: sys.stdin.readline().rstrip()
n,m,k=map(int,input().split())
LR=[tuple(int(i) for i in input().split()) for _ in range(m)]
E=[[0]*n for _ in range(n)]
for l,r in LR:
  E[l-1][l-1]+=1
  if r<n:
    E[l-1][r]-=1
    E[r][l-1]-=1
    E[r][r]+=1
for i in range(n):
  for j in range(n-1):
    E[i][j+1]+=E[i][j]
for i in range(n):
  for j in range(n-1):
    E[j+1][i]+=E[j][i]

mod=10**9+7
def mul(a,b):
  c=[[0]*len(b[0]) for i in range(len(a))]
  for i in range(len(a)):
    for k in range(len(b)):
      for j in range(len(b[0])):
        c[i][j]=(c[i][j]+a[i][k]*b[k][j])%mod
  return c

def matrix_pow(a,x):
  b=[[0]*len(a) for i in range(len(a))]
  for i in range(len(a)):
    b[i][i] = 1
	
  while x>0:
    if x&1==1:
      b=mul(a,b)
    a=mul(a,a)
    x>>=1		
  return b
EK=matrix_pow(E,k)
print(EK[0][n-1])
0