結果

問題 No.936 Are
ユーザー vwxyzvwxyz
提出日時 2024-04-25 04:05:18
言語 PyPy3
(7.3.15)
結果
TLE  
実行時間 -
コード長 2,467 bytes
コンパイル時間 173 ms
コンパイル使用メモリ 82,176 KB
実行使用メモリ 92,140 KB
最終ジャッジ日時 2024-04-25 04:05:25
合計ジャッジ時間 4,979 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 221 ms
84,044 KB
testcase_01 TLE -
testcase_02 -- -
testcase_03 -- -
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 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

def attack(L1,R1,L2,R2):
    retu=[]
    if L1 and L2:
        retu.append(((L1+L2)%5,R2))
    if L1 and R2:
        retu.append((L2,(L1+R2)%5))
    if R1 and L2:
        retu.append(((R1+L2)%5,R2))
    if R1 and R2:
        retu.append((L2,(R1+R2)%5))
    return retu

def split(L,R):
    retu=[]
    for l in range(5):
        for r in range(5):
            if (l,r)==(0,0):
                continue
            if (l+r==L+R or l+r==(L+R)%5) and {l,r}!={L,R}:
                retu.append((l,r))
    return retu

def lose(L1,R1,L2,R2):
    if L2 and R2:
        return False
    s=L2+R2
    if (-s)%5 in (L1,R1):
        return True
    return False

N,K=map(int,input().split())
mod=10**9+7
def idx(L1,L2,R1,R2):
    return L1*125+R1*25+L2*5+R2
dp=[0]*625
for cnt in range(K,-1,-1):
    prev=dp
    dp=[0]*625
    for L1 in range(5):
        for R1 in range(5):
            for L2 in range(5):
                for R2 in range(5):
                    if (L1,R1)==(0,0):
                        dp[idx(L1,R1,L2,R2)]=0
                    elif (L2,R2)==(0,0):
                        dp[idx(L1,R1,L2,R2)]=1
                    else:
                        if cnt%2!=N%2:
                            if not (0,0) in attack(L2,R2,L1,R1):
                                not_lose=False
                                for L,R in split(L2,R2):
                                    not_lose|=not lose(L1,R1,L,R)
                                for L,R in attack(L2,R2,L1,R1):
                                    not_lose|=not lose(L,R,L2,R2)

                                for L,R in split(L2,R2):
                                    if not_lose and lose(L1,R1,L,R):
                                        continue
                                    dp[idx(L1,R1,L2,R2)]+=prev[idx(L1,R1,L,R)]
                                for L,R in attack(L2,R2,L1,R1):
                                    if not_lose and lose(L,R,L2,R2):
                                        continue
                                    dp[idx(L1,R1,L2,R2)]+=prev[idx(L,R,L2,R2)]
                        else:
                            for L,R in split(L1,R1):
                                dp[idx(L1,R1,L2,R2)]+=prev[idx(L,R,L2,R2)]
                            for L,R in attack(L1,R1,L2,R2):
                                dp[idx(L1,R1,L2,R2)]+=prev[idx(L1,R1,L,R)]
                        dp[idx(L1,R1,L2,R2)]%=mod
L1,R1,L2,R2=map(int,input().split())
ans=dp[idx(L1,R1,L2,R2)]
print(ans)
0