結果

問題 No.1354 Sambo's Treasure
ユーザー 👑 timitimi
提出日時 2021-01-20 20:36:06
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,382 bytes
コンパイル時間 513 ms
コンパイル使用メモリ 87,296 KB
実行使用メモリ 849,816 KB
最終ジャッジ日時 2023-08-25 00:43:33
合計ジャッジ時間 8,297 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,544 KB
testcase_01 WA -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 73 ms
71,308 KB
testcase_06 RE -
testcase_07 AC 73 ms
71,364 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 AC 72 ms
71,028 KB
testcase_12 AC 74 ms
71,200 KB
testcase_13 RE -
testcase_14 RE -
testcase_15 AC 75 ms
71,308 KB
testcase_16 AC 73 ms
71,440 KB
testcase_17 RE -
testcase_18 RE -
testcase_19 AC 77 ms
71,184 KB
testcase_20 AC 72 ms
71,016 KB
testcase_21 RE -
testcase_22 AC 72 ms
71,304 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,N))
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+2)]
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]
    a,b=gx-sx,gy-sy
    F=[[[0]*(b+3) for w in range(a+3)]for h in range(K+3)]
    for k in range(K+1):
        F[k][0][0]=dp[k][sx][sy]
    dp=F
    for k in range(K,-1,-1):
        for x in range(gx-sx+1):
            for y in range(gy-sy+1):
                dp[k][x][y]%=mod
                if E[sx+x][sy+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][gx-sx][gy-sy]
    ans%=mod
print(ans)
0