結果

問題 No.1354 Sambo's Treasure
ユーザー 👑 timitimi
提出日時 2021-01-20 17:12:51
言語 PyPy3
(7.3.15)
結果
MLE  
実行時間 -
コード長 1,227 bytes
コンパイル時間 731 ms
コンパイル使用メモリ 86,820 KB
実行使用メモリ 840,472 KB
最終ジャッジ日時 2023-08-24 21:02:53
合計ジャッジ時間 5,215 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,300 KB
testcase_01 AC 72 ms
71,132 KB
testcase_02 AC 86 ms
76,476 KB
testcase_03 AC 71 ms
71,292 KB
testcase_04 AC 72 ms
71,292 KB
testcase_05 AC 72 ms
71,080 KB
testcase_06 AC 71 ms
71,380 KB
testcase_07 AC 71 ms
70,936 KB
testcase_08 AC 72 ms
71,080 KB
testcase_09 AC 73 ms
71,236 KB
testcase_10 AC 72 ms
71,296 KB
testcase_11 AC 71 ms
71,288 KB
testcase_12 AC 71 ms
70,936 KB
testcase_13 AC 71 ms
71,212 KB
testcase_14 AC 73 ms
71,208 KB
testcase_15 AC 72 ms
71,392 KB
testcase_16 AC 78 ms
75,876 KB
testcase_17 AC 74 ms
71,384 KB
testcase_18 AC 73 ms
71,260 KB
testcase_19 AC 72 ms
71,240 KB
testcase_20 AC 72 ms
71,240 KB
testcase_21 AC 72 ms
71,240 KB
testcase_22 AC 71 ms
71,300 KB
testcase_23 MLE -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
testcase_34 -- -
testcase_35 -- -
testcase_36 -- -
testcase_37 -- -
testcase_38 -- -
testcase_39 -- -
testcase_40 -- -
testcase_41 -- -
testcase_42 -- -
testcase_43 -- -
testcase_44 -- -
testcase_45 -- -
testcase_46 -- -
testcase_47 -- -
testcase_48 -- -
testcase_49 -- -
testcase_50 -- -
testcase_51 -- -
testcase_52 -- -
testcase_53 -- -
testcase_54 -- -
testcase_55 -- -
testcase_56 -- -
testcase_57 -- -
testcase_58 -- -
testcase_59 -- -
testcase_60 -- -
testcase_61 -- -
testcase_62 -- -
testcase_63 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

N,M,L,K=map(int, input().split())
C,T=[],[]
for i in range(M):
    x,y=map(int, input().split())
    C.append((x+y,x,y))
for i in range(L):
    x,y=map(int, input().split())
    T.append((x+y,x,y))
C=sorted(C)
T=sorted(T)
C.append((2*N+2,N+1,N+1))
E=[[0]*(N+2) for i in range(N+2)]
#1:check 2:tiger
for a,x,y in T:
    E[x][y]=2
#print(C)
#print(T)
dp=[[[0]*(N+3) for w in range(N+3)]for h in range(K+3)]
dp[K][0][0]=1
mod=998244353
for i in range(M+1):
    if i==0:
        sx,sy=0,0
        gx,gy=C[0][1],C[0][2]
    else:
        sx,sy=C[i-1][1],C[i-1][2]
        gx,gy=C[i][1],C[i][2]
    for k in range(K,-1,-1):
        for x in range(sx,gx+1):
            for y in range(sy,gy+1):
                dp[k][x][y]%=mod
                if E[x][y]==0:
                    if x+1<=gx:
                        dp[k][x+1][y]+=dp[k][x][y]
                    if y+1<=gy:
                        dp[k][x][y+1]+=dp[k][x][y]
                else:
                    if k>0:
                        if x+1<=gx:
                            dp[k-1][x+1][y]+=dp[k][x][y]
                        if y+1<=gy:
                            dp[k-1][x][y+1]+=dp[k][x][y]

ans=0 
for k in range(K+1):
    ans+=dp[k][N][N]
    ans%=mod
print(ans)
0