結果
| 問題 |
No.52 よくある文字列の問題
|
| コンテスト | |
| ユーザー |
明智重蔵
|
| 提出日時 | 2015-10-31 21:17:49 |
| 言語 | C#(csc) (csc 3.9.0) |
| 結果 |
AC
|
| 実行時間 | 29 ms / 5,000 ms |
| コード長 | 1,942 bytes |
| コンパイル時間 | 852 ms |
| コンパイル使用メモリ | 112,696 KB |
| 実行使用メモリ | 28,072 KB |
| 最終ジャッジ日時 | 2024-09-22 05:23:33 |
| 合計ジャッジ時間 | 1,731 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
コンパイルメッセージ
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;
class Program
{
static string InputPattern = "InputX";
static List<string> GetInputList()
{
var WillReturn = new List<string>();
if (InputPattern == "Input1") {
WillReturn.Add("abc");
//4
//abc、acb、cab、cbaの4通りがある
}
else if (InputPattern == "Input2") {
WillReturn.Add("aab");
//3
//aab、aba、baaの3通りがある
}
else if (InputPattern == "Input3") {
WillReturn.Add("aaaaaaaaaa");
//1
//どのようにしてもaaaaaaaaaaにしかならない
}
else {
string wkStr;
while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
}
return WillReturn;
}
struct JyoutaiDef
{
internal string CurrStr;
internal string CreateStr;
}
static void Main()
{
List<string> InputList = GetInputList();
string S = InputList[0];
var stk = new Stack<JyoutaiDef>();
JyoutaiDef WillPush;
WillPush.CurrStr = S;
WillPush.CreateStr = "";
stk.Push(WillPush);
var CreateStrSet = new HashSet<string>();
while (stk.Count > 0) {
JyoutaiDef Popped = stk.Pop();
//クリア判定
if (Popped.CurrStr == "") {
CreateStrSet.Add(Popped.CreateStr);
continue;
}
Action<int> PushSyori = pRemoveInd =>
{
WillPush.CurrStr = Popped.CurrStr.Remove(pRemoveInd, 1);
WillPush.CreateStr = Popped.CreateStr + Popped.CurrStr[pRemoveInd];
stk.Push(WillPush);
};
PushSyori(0);
PushSyori(Popped.CurrStr.Length - 1);
}
Console.WriteLine(CreateStrSet.Count);
}
}
明智重蔵