結果
| 問題 |
No.2926 Botaoshi
|
| コンテスト | |
| ユーザー |
aketijyuuzou
|
| 提出日時 | 2025-02-11 17:41:13 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 53 ms / 2,000 ms |
| コード長 | 2,567 bytes |
| コンパイル時間 | 6,150 ms |
| コンパイル使用メモリ | 110,312 KB |
| 実行使用メモリ | 30,948 KB |
| 最終ジャッジ日時 | 2025-02-11 17:41:23 |
| 合計ジャッジ時間 | 9,319 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 42 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System;
using System.Collections.Generic;
using System.Linq;
// https://yukicoder.me/problems/no/2926
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("3");
WillReturn.Add("..L");
}
else if (InputPattern == "Input2") {
WillReturn.Add("6");
WillReturn.Add("..L..R");
}
else if (InputPattern == "Input3") {
WillReturn.Add("8");
WillReturn.Add(".RL..U..");
}
else if (InputPattern == "Input4") {
WillReturn.Add("30");
WillReturn.Add(".....R.....U...R..L.........L.");
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
const long Hou = 998244353;
static void Main()
{
List<string> InputList = GetInputList();
char[] CharArr = InputList[1].ToCharArray();
// 場合の数[Lが使用不可か?]
// 0 Lが使用可
// 1 Lが使用不可
long[] PrevDP = new long[2];
PrevDP[0] = 1;
foreach (char EachChar in CharArr) {
long[] CurrDP = new long[2];
for (long I = 0; I <= 1; I++) {
if (PrevDP[I] == 0) continue;
Action<char> SendAct = (pNewChar) =>
{
if (pNewChar == 'L' && I == 1) return;
if (pNewChar == 'R') {
CurrDP[1] += PrevDP[I];
CurrDP[1] %= Hou;
}
else {
CurrDP[0] += PrevDP[I];
CurrDP[0] %= Hou;
}
};
if (EachChar == 'L') {
SendAct('L');
}
if (EachChar == 'R') {
SendAct('R');
}
if (EachChar == 'U') {
SendAct('U');
}
if (EachChar == '.') {
SendAct('L');
SendAct('R');
SendAct('U');
}
}
PrevDP = CurrDP;
}
long Answer = 0;
foreach (long EachLong in PrevDP) {
Answer += EachLong;
Answer %= Hou;
}
Console.WriteLine(Answer);
}
}
aketijyuuzou