結果
問題 |
No.2926 Botaoshi
|
ユーザー |
![]() |
提出日時 | 2024-10-14 13:05:25 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 10 ms / 2,000 ms |
コード長 | 922 bytes |
コンパイル時間 | 425 ms |
コンパイル使用メモリ | 41,472 KB |
最終ジャッジ日時 | 2025-02-24 19:26:09 |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 42 |
コンパイルメッセージ
main.cpp: In function ‘int main()’: main.cpp:33:8: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result] 33 | scanf("%d%s", &n, s); | ~~~~~^~~~~~~~~~~~~~~
ソースコード
/* -*- coding: utf-8 -*- * * 2926.cc: No.2926 Botaoshi - yukicoder */ #include<cstdio> #include<algorithm> using namespace std; /* constant */ const int MAX_N = 200000; const int MOD = 998244353; enum { L, R, U }; /* typedef */ /* global variables */ char s[MAX_N + 4]; int dp[MAX_N + 1][3]; /* subroutines */ inline void addmod(int &a, int b) { a = (a + b) % MOD; } /* main */ int main() { int n; scanf("%d%s", &n, s); dp[0][U] = 1; for (int i = 0; i < n; i++) for (int j = 0; j < 3; j++) if (dp[i][j]) { if (s[i] == '.') { for (int j1 = 0; j1 < 3; j1++) if (! (j == R && j1 == L)) addmod(dp[i + 1][j1], dp[i][j]); } else { int j1 = (s[i] == 'L') ? L : (s[i] == 'R') ? R : U; if (! (j == R && j1 == L)) addmod(dp[i + 1][j1], dp[i][j]); } } int sum = 0; for (int j = 0; j < 3; j++) addmod(sum, dp[n][j]); printf("%d\n", sum); return 0; }