結果
問題 | No.1766 Tatsujin Remix |
ユーザー | mkawa2 |
提出日時 | 2021-11-27 12:33:59 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 152 ms / 2,000 ms |
コード長 | 1,525 bytes |
コンパイル時間 | 159 ms |
コンパイル使用メモリ | 82,304 KB |
実行使用メモリ | 86,644 KB |
最終ジャッジ日時 | 2024-06-30 03:32:29 |
合計ジャッジ時間 | 4,073 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
52,480 KB |
testcase_01 | AC | 38 ms
52,352 KB |
testcase_02 | AC | 37 ms
52,480 KB |
testcase_03 | AC | 38 ms
52,608 KB |
testcase_04 | AC | 94 ms
76,288 KB |
testcase_05 | AC | 91 ms
76,288 KB |
testcase_06 | AC | 101 ms
76,672 KB |
testcase_07 | AC | 90 ms
76,288 KB |
testcase_08 | AC | 65 ms
70,144 KB |
testcase_09 | AC | 120 ms
82,560 KB |
testcase_10 | AC | 119 ms
82,304 KB |
testcase_11 | AC | 123 ms
81,920 KB |
testcase_12 | AC | 128 ms
82,176 KB |
testcase_13 | AC | 134 ms
82,556 KB |
testcase_14 | AC | 142 ms
86,280 KB |
testcase_15 | AC | 130 ms
86,340 KB |
testcase_16 | AC | 133 ms
86,284 KB |
testcase_17 | AC | 133 ms
86,272 KB |
testcase_18 | AC | 135 ms
86,492 KB |
testcase_19 | AC | 152 ms
86,388 KB |
testcase_20 | AC | 151 ms
86,528 KB |
testcase_21 | AC | 136 ms
86,524 KB |
testcase_22 | AC | 135 ms
86,264 KB |
testcase_23 | AC | 138 ms
86,388 KB |
testcase_24 | AC | 91 ms
86,272 KB |
testcase_25 | AC | 136 ms
86,644 KB |
ソースコード
import sys # sys.setrecursionlimit(200005) int1 = lambda x: int(x)-1 p2D = lambda x: print(*x, sep="\n") 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 = 18446744073709551615 # inf = 4294967295 # md = 10**9+7 md = 998244353 n = II() aa = [] for _ in range(n): aa += [".dk".find(c) for c in SI()] n *= 16 # print(aa) dp = [0]*3 a = aa[0] if a == 0: dp[0] = 1 if n > 1 and aa[1] > 0: dp[3-aa[1]] = 1 else: dp[1] = 1 dp[2] = 1 else: dp[a] = 1 for i, a in enumerate(aa[1:], 1): ndp = [0]*3 for j in range(3): if dp[j] == 0: continue if a == 0: for nj in range(3): if i & 1 == 0 and j > 0 and nj == 0: continue if i & 1 and j == 0 and nj > 0: continue if i+1 < n and a == 0 and aa[i+1] > 0 and nj == aa[i+1]: continue ndp[nj] += dp[j] if i & 1 and j == 0: continue if a == 1: ndp[a] += dp[j] if a == 2: ndp[a] += dp[j] for j in range(3): ndp[j] %= md dp = ndp # print(i, a, dp) print(sum(dp)%md)