結果

問題 No.39 桁の数字を入れ替え
ユーザー 明智重蔵明智重蔵
提出日時 2015-07-25 16:33:47
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 1,694 bytes
コンパイル時間 5,002 ms
コンパイル使用メモリ 107,252 KB
実行使用メモリ 25,668 KB
最終ジャッジ日時 2023-09-24 12:21:48
合計ジャッジ時間 7,090 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 51 ms
21,568 KB
testcase_01 AC 52 ms
21,372 KB
testcase_02 AC 52 ms
23,512 KB
testcase_03 AC 52 ms
21,644 KB
testcase_04 AC 54 ms
21,560 KB
testcase_05 AC 54 ms
21,336 KB
testcase_06 AC 53 ms
21,464 KB
testcase_07 AC 56 ms
21,456 KB
testcase_08 AC 55 ms
21,456 KB
testcase_09 AC 54 ms
23,356 KB
testcase_10 AC 55 ms
23,464 KB
testcase_11 AC 56 ms
21,456 KB
testcase_12 WA -
testcase_13 AC 56 ms
21,356 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
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;
using System.Linq;

class Program
{
    static string InputPattern = "Input5";

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

        if (InputPattern == "Input1") {
            WillReturn.Add("12");
        }
        else if (InputPattern == "Input2") {
            WillReturn.Add("21");
        }
        else if (InputPattern == "Input3") {
            WillReturn.Add("1122");
        }
        else if (InputPattern == "Input4") {
            WillReturn.Add("999999999");
        }
        else {
            string wkStr;
            while ((wkStr = Console.ReadLine()) != null) WillReturn.Add(wkStr);
        }
        return WillReturn;
    }

    static void Main()
    {
        List<string> InputList = GetInputList();
        char[] StrArr = InputList[0].ToCharArray();
        char[] DescStr = StrArr.OrderByDescending(X => X).ToArray(); ;

        int DiffFromFirst = -1;
        int DiffFromLast = -1;
        for (int I = 0; I <= StrArr.Length - 1; I++) {
            if (StrArr[I] != DescStr[I]) {
                DiffFromFirst = I;
                break;
            }
        }
        for (int I = StrArr.Length - 1; 0 <= I; I--) {
            if (StrArr[I] != DescStr[I]) {
                DiffFromLast = I;
                break;
            }
        }

        if (DiffFromFirst == -1 && DiffFromLast == -1) {
            Console.WriteLine(StrArr);
            return;
        }
        char SankakuWK = StrArr[DiffFromFirst];
        StrArr[DiffFromFirst] = StrArr[DiffFromLast];
        StrArr[DiffFromLast] = SankakuWK;
        Console.WriteLine(new string(StrArr));
    }
}
0