結果
問題 | No.2926 Botaoshi |
ユーザー | 電たくT |
提出日時 | 2024-10-12 16:43:10 |
言語 | PyPy3 (7.3.15) |
結果 |
RE
|
実行時間 | - |
コード長 | 1,351 bytes |
コンパイル時間 | 282 ms |
コンパイル使用メモリ | 82,408 KB |
実行使用メモリ | 111,488 KB |
最終ジャッジ日時 | 2024-10-12 16:43:15 |
合計ジャッジ時間 | 5,635 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 40 ms
52,480 KB |
testcase_01 | AC | 38 ms
52,096 KB |
testcase_02 | AC | 39 ms
52,224 KB |
testcase_03 | AC | 39 ms
52,480 KB |
testcase_04 | AC | 39 ms
52,480 KB |
testcase_05 | AC | 40 ms
52,096 KB |
testcase_06 | AC | 44 ms
51,968 KB |
testcase_07 | RE | - |
testcase_08 | AC | 40 ms
52,224 KB |
testcase_09 | AC | 40 ms
52,480 KB |
testcase_10 | AC | 39 ms
51,840 KB |
testcase_11 | RE | - |
testcase_12 | AC | 121 ms
109,048 KB |
testcase_13 | AC | 115 ms
108,672 KB |
testcase_14 | AC | 116 ms
108,988 KB |
testcase_15 | AC | 40 ms
52,096 KB |
testcase_16 | AC | 94 ms
90,540 KB |
testcase_17 | AC | 122 ms
107,904 KB |
testcase_18 | AC | 67 ms
74,112 KB |
testcase_19 | AC | 92 ms
87,680 KB |
testcase_20 | AC | 82 ms
81,280 KB |
testcase_21 | AC | 85 ms
85,248 KB |
testcase_22 | AC | 87 ms
87,424 KB |
testcase_23 | AC | 54 ms
66,816 KB |
testcase_24 | AC | 90 ms
89,168 KB |
testcase_25 | AC | 62 ms
73,088 KB |
testcase_26 | AC | 118 ms
105,088 KB |
testcase_27 | AC | 75 ms
85,504 KB |
testcase_28 | AC | 50 ms
64,512 KB |
testcase_29 | AC | 49 ms
62,848 KB |
testcase_30 | AC | 53 ms
72,064 KB |
testcase_31 | AC | 61 ms
71,808 KB |
testcase_32 | AC | 78 ms
82,816 KB |
testcase_33 | AC | 99 ms
90,752 KB |
testcase_34 | AC | 101 ms
88,832 KB |
testcase_35 | AC | 56 ms
64,896 KB |
testcase_36 | AC | 116 ms
109,056 KB |
testcase_37 | AC | 117 ms
108,160 KB |
testcase_38 | AC | 117 ms
108,288 KB |
testcase_39 | AC | 117 ms
108,672 KB |
testcase_40 | AC | 117 ms
108,672 KB |
testcase_41 | AC | 120 ms
111,488 KB |
testcase_42 | RE | - |
testcase_43 | RE | - |
testcase_44 | AC | 92 ms
93,756 KB |
testcase_45 | RE | - |
ソースコード
N = int(input()) S = input() dp = [[0,0,0] for _ in range(N)] mod = 998244353 if S[0] == "L": dp[0][0] = 1 elif S[0] == "U": dp[0][1] = 1 elif S[0] == "R": dp[0][2] = "1" else: if len(S) == 1: dp[0][0] = 3 else: if S[1] == "L": dp[0][0],dp[0][1] = 1,1 else: dp[0] = [1,1,1] for a in range(1,N-1): X = [0,0,0] P = dp[a-1] if S[a] == ".": if S[a+1] == "L": X[0] = P[0] + P[1] X[1] = P[0] + P[1] + P[2] else: X[0] = P[0] + P[1] X[1] = P[1] + P[2] + P[0] X[2] = P[1] + P[2] + P[0] for b in range(3): X[b] %= mod elif S[a] == "L": X[0] = P[1] + P[0] X[0] %= mod elif S[a] == "U": X[1] = P[1] + P[2] + P[0] X[1] %= mod elif S[a] == "R": if S[a+1] == "L": pass else: X[2] = P[1] + P[2] + P[0] X[2] %= mod dp[a] = X if len(S) >= 2: X = [0,0,0] P = dp[N-2] if S[N-1] == ".": X[0] = P[1] + P[0] X[1] = P[1] + P[2] + P[0] X[2] = P[1] + P[2] + P[0] elif S[N-1] == "L": X[0] = P[1] + P[0] else: X[1] = P[1] + P[2] + P[0] for b in range(3): X[b] %= mod dp[N-1] = X print(sum(dp[N-1])%mod)