結果

問題 No.1703 Much Matching
ユーザー harurunharurun
提出日時 2021-10-02 02:35:01
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 706 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 375 ms
コンパイル使用メモリ 86,476 KB
実行使用メモリ 90,028 KB
最終ジャッジ日時 2023-09-30 09:42:54
合計ジャッジ時間 9,937 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
70,912 KB
testcase_01 AC 76 ms
70,944 KB
testcase_02 AC 77 ms
71,068 KB
testcase_03 AC 92 ms
75,724 KB
testcase_04 AC 96 ms
75,456 KB
testcase_05 AC 98 ms
75,796 KB
testcase_06 AC 272 ms
80,056 KB
testcase_07 AC 114 ms
77,188 KB
testcase_08 AC 310 ms
90,028 KB
testcase_09 AC 322 ms
85,804 KB
testcase_10 AC 141 ms
78,836 KB
testcase_11 AC 168 ms
82,900 KB
testcase_12 AC 116 ms
77,604 KB
testcase_13 AC 197 ms
79,216 KB
testcase_14 AC 111 ms
76,316 KB
testcase_15 AC 167 ms
82,076 KB
testcase_16 AC 219 ms
78,760 KB
testcase_17 AC 233 ms
79,052 KB
testcase_18 AC 105 ms
76,788 KB
testcase_19 AC 368 ms
84,600 KB
testcase_20 AC 128 ms
77,272 KB
testcase_21 AC 415 ms
83,648 KB
testcase_22 AC 246 ms
82,256 KB
testcase_23 AC 208 ms
82,544 KB
testcase_24 AC 110 ms
76,564 KB
testcase_25 AC 127 ms
78,744 KB
testcase_26 AC 186 ms
82,276 KB
testcase_27 AC 248 ms
81,364 KB
testcase_28 AC 406 ms
84,644 KB
testcase_29 AC 171 ms
82,536 KB
testcase_30 AC 192 ms
81,312 KB
testcase_31 AC 125 ms
78,704 KB
testcase_32 AC 258 ms
82,640 KB
testcase_33 AC 223 ms
85,092 KB
testcase_34 AC 117 ms
77,484 KB
testcase_35 AC 143 ms
79,752 KB
testcase_36 AC 706 ms
85,592 KB
testcase_37 AC 134 ms
86,020 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def lcs(S,T,A):
  dp=[[0]*(len(T)+1)for _ in[0]*(len(S)+1)]
  for i in range(1,len(S)+1):
    for j in range(1,len(T)+1):
      if A[S[i-1]][T[j-1]]==1:
        dp[i][j]=dp[i-1][j-1]+1
      else:
        dp[i][j]=max(dp[i-1][j],dp[i][j-1])
  length=dp[len(S)][len(T)]
  return length

def main():
  N,M,Q=map(int,input().split())
  A=[[0]*M for i in range(N)]
  for i in range(Q):
    a,b=map(int,input().split())
    A[a-1][b-1]=1
  S=list(range(N))
  T=list(range(M))
  ans=lcs(S,T,A)
  print(ans)
  return

main()
0