結果
問題 | No.2926 Botaoshi |
ユーザー |
![]() |
提出日時 | 2024-10-12 15:45:05 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 84 ms / 2,000 ms |
コード長 | 1,263 bytes |
コンパイル時間 | 200 ms |
コンパイル使用メモリ | 82,176 KB |
実行使用メモリ | 77,312 KB |
最終ジャッジ日時 | 2024-10-12 15:45:14 |
合計ジャッジ時間 | 4,711 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 42 |
ソースコード
from collections import defaultdict, deque, Counter# from functools import cache# import copyfrom itertools import combinations, permutations, product, accumulate, groupby, chain# from more_itertools import distinct_permutationsfrom heapq import heapify, heappop, heappushimport mathimport bisect# from pprint import pprintfrom random import randint, shuffle, randrange# from sortedcontainers import SortedSet, SortedList, SortedDictimport sys# sys.setrecursionlimit(2000000)input = lambda: sys.stdin.readline().rstrip('\n')inf = float('inf')mod1 = 10**9+7mod2 = 998244353def ceil_div(x, y): return -(-x//y)#################################################N = int(input())S = input()dp = [0]*3if S[0] == "L":dp[0] = 1elif S[0] == "R":dp[1] = 1elif S[0] == "U":dp[2] = 1else:dp[0] = 1dp[1] = 1dp[2] = 1for i in range(1, N):s = S[i]ndp = [0]*3if s == "L":ndp[0] = dp[0]+dp[2]elif s == "R":ndp[1] = dp[0]+dp[1]+dp[2]elif s == "U":ndp[2] = dp[0]+dp[1]+dp[2]else:ndp[0] = dp[0]+dp[2]ndp[1] = dp[0]+dp[1]+dp[2]ndp[2] = dp[0]+dp[1]+dp[2]dp = ndpdp[0] %= mod2dp[1] %= mod2dp[2] %= mod2print(sum(dp)%mod2)