結果
問題 | No.936 Are |
ユーザー | mkawa2 |
提出日時 | 2022-05-19 00:53:00 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 2,783 ms / 3,000 ms |
コード長 | 3,014 bytes |
コンパイル時間 | 225 ms |
コンパイル使用メモリ | 82,172 KB |
実行使用メモリ | 81,412 KB |
最終ジャッジ日時 | 2024-09-17 05:11:27 |
合計ジャッジ時間 | 25,979 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 102 ms
77,104 KB |
testcase_01 | AC | 97 ms
76,952 KB |
testcase_02 | AC | 2,783 ms
81,412 KB |
testcase_03 | AC | 119 ms
76,920 KB |
testcase_04 | AC | 121 ms
77,036 KB |
testcase_05 | AC | 106 ms
77,004 KB |
testcase_06 | AC | 110 ms
76,820 KB |
testcase_07 | AC | 107 ms
76,804 KB |
testcase_08 | AC | 87 ms
76,284 KB |
testcase_09 | AC | 116 ms
77,060 KB |
testcase_10 | AC | 99 ms
76,824 KB |
testcase_11 | AC | 112 ms
76,732 KB |
testcase_12 | AC | 101 ms
76,960 KB |
testcase_13 | AC | 738 ms
78,072 KB |
testcase_14 | AC | 2,288 ms
80,760 KB |
testcase_15 | AC | 985 ms
78,204 KB |
testcase_16 | AC | 1,474 ms
79,984 KB |
testcase_17 | AC | 1,304 ms
79,188 KB |
testcase_18 | AC | 701 ms
77,880 KB |
testcase_19 | AC | 2,290 ms
81,180 KB |
testcase_20 | AC | 2,305 ms
80,856 KB |
testcase_21 | AC | 2,411 ms
80,788 KB |
testcase_22 | AC | 1,307 ms
78,896 KB |
testcase_23 | AC | 2,417 ms
81,124 KB |
testcase_24 | AC | 2,421 ms
81,324 KB |
ソースコード
import sys sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 pDB = lambda *x: print(*x, end="\n", file=sys.stderr) p2D = lambda x: print(*x, sep="\n", end="\n\n", file=sys.stderr) def II(): return int(sys.stdin.readline()) def LI(): return list(map(int, sys.stdin.readline().split())) def LLI(rows_number): return [LI() for _ in range(rows_number)] def LI1(): return list(map(int1, sys.stdin.readline().split())) def LLI1(rows_number): return [LI1() for _ in range(rows_number)] def SI(): return sys.stdin.readline().rstrip() dij = [(0, 1), (-1, 0), (0, -1), (1, 0)] # dij = [(0, 1), (-1, 0), (0, -1), (1, 0), (1, 1), (1, -1), (-1, 1), (-1, -1)] inf = (1 << 63)-1 # inf = (1 << 31)-1 md = 10**9+7 # md = 998244353 from collections import defaultdict def pack(aa): if aa[0] == aa[1] == 0: return aa[-1] if aa[2] == aa[3] == 0: return aa[-1] res = 0 for a in aa: res = res*5+a return res def move(l, r, s, t): def push(l, r, x, y): x %= 5 y %= 5 i = 1 if x == y == 0: i = 0 elif l*r == 0 and (l+r+x == 5 or l+r+y == 5): i = 2 res[i].append((l, r, x, y)) res = [[], [], []] if s and l: push(l, r, s+l, t) if t and l: push(l, r, s, t+l) if s and r: push(l, r, s+r, t) if t and r: push(l, r, s, t+r) for a in range(5): if a > l+r: break b = (l+r-a)%5 if a == b == 0 or a == l or a == r: continue push(a, b, s, t) return res n, k = LI() l1, r1, l2, r2 = LI() to = defaultdict(list) for b in range(5): for a in range(5): if a == b == 0: continue for d in range(5): for c in range(5): if c == d == 0: continue u0 = pack([a, b, c, d, 0]) u1 = pack([c, d, a, b, 1]) ret = move(a, b, c, d) # pDB(a, b, c, d, u0, u1, ret) if ret[0]: for l, r, s, t in ret[0]: v1 = pack([l, r, s, t, 1]) v0 = pack([s, t, l, r, 0]) to[u0].append(v1) to[u1].append(v0) for l, r, s, t in ret[1]: v1 = pack([l, r, s, t, 1]) to[u0].append(v1) elif ret[1]: for l, r, s, t in ret[1]: v1 = pack([l, r, s, t, 1]) v0 = pack([s, t, l, r, 0]) to[u0].append(v1) to[u1].append(v0) else: for l, r, s, t in ret[2]: v0 = pack([s, t, l, r, 0]) to[u1].append(v0) # pDB(to) dp = defaultdict(int) u = pack([l1, r1, l2, r2, n]) dp[u] = 1 # pDB(dp) ans = 0 for _ in range(k): ndp = defaultdict(int) for u, c in dp.items(): # pDB(u,c,to[u]) for v in to[u]: ndp[v] = (ndp[v]+c)%md dp = ndp ans += dp[1] ans %= md # pDB(ans, dp) print(ans)