結果

問題 No.170 スワップ文字列(Easy)
ユーザー 明智重蔵明智重蔵
提出日時 2015-08-29 07:15:58
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 1,408 bytes
コンパイル時間 2,626 ms
コンパイル使用メモリ 104,132 KB
実行使用メモリ 32,492 KB
最終ジャッジ日時 2023-08-24 16:21:44
合計ジャッジ時間 5,191 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 56 ms
22,368 KB
testcase_01 AC 121 ms
32,492 KB
testcase_02 AC 56 ms
22,332 KB
testcase_03 AC 57 ms
24,308 KB
testcase_04 AC 58 ms
24,236 KB
testcase_05 AC 121 ms
30,520 KB
testcase_06 AC 122 ms
32,492 KB
testcase_07 AC 56 ms
22,236 KB
testcase_08 AC 56 ms
22,280 KB
testcase_09 AC 56 ms
22,308 KB
testcase_10 AC 89 ms
28,464 KB
testcase_11 AC 56 ms
22,352 KB
testcase_12 AC 57 ms
22,196 KB
testcase_13 AC 57 ms
22,244 KB
testcase_14 AC 56 ms
22,336 KB
testcase_15 AC 57 ms
22,296 KB
testcase_16 AC 57 ms
22,404 KB
testcase_17 AC 56 ms
22,356 KB
testcase_18 AC 57 ms
22,388 KB
testcase_19 AC 56 ms
20,368 KB
testcase_20 AC 57 ms
22,440 KB
testcase_21 AC 56 ms
22,272 KB
testcase_22 AC 57 ms
22,300 KB
testcase_23 AC 58 ms
24,276 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;

class Program
{
    static string InputPattern = "Input4";

    static List<string> GetInputList()
    {
        var WillReturn = new List<string>();

        if (InputPattern == "Input1") {
            WillReturn.Add("ABC");
            //5
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("DDDDDD");
            //0
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("XYZYX");
            //29
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        string S = InputList[0];

        var stk = new Stack<string>();
        stk.Push(S);
        var VisitedSet = new HashSet<string>() { S };

        while (stk.Count > 0) {
            string Popped = stk.Pop();

            for (int I = 0; I <= S.Length - 2; I++) {
                char[] NewCharArr = Popped.ToCharArray();
                NewCharArr[I] = Popped[I + 1];
                NewCharArr[I + 1] = Popped[I];
                string NewStr = new string(NewCharArr);
                if (VisitedSet.Add(NewStr))
                    stk.Push(NewStr);
            }
        }
        Console.WriteLine(VisitedSet.Count - 1);
    }
}
0