結果

問題 No.536 人工知能
ユーザー くれちーくれちー
提出日時 2017-04-04 01:47:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 27 ms / 1,000 ms
コード長 1,211 bytes
コンパイル時間 904 ms
コンパイル使用メモリ 106,752 KB
実行使用メモリ 19,840 KB
最終ジャッジ日時 2024-07-08 08:35:08
合計ジャッジ時間 1,859 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 26 ms
19,456 KB
testcase_01 AC 27 ms
19,584 KB
testcase_02 AC 25 ms
19,584 KB
testcase_03 AC 25 ms
19,712 KB
testcase_04 AC 26 ms
19,456 KB
testcase_05 AC 26 ms
19,840 KB
testcase_06 AC 25 ms
19,712 KB
testcase_07 AC 26 ms
19,456 KB
testcase_08 AC 25 ms
19,456 KB
testcase_09 AC 26 ms
19,456 KB
testcase_10 AC 26 ms
19,200 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.IO;
using System.Linq;

class Program
{
    static void Assert(bool expr, string message)
    {
        if (!expr)
        {
            Console.Error.WriteLine("Error: " + message);
            Environment.Exit(1);
        }
    }

    static string GetCheckedInput(string input)
    {
        Assert(input.EndsWith(Environment.NewLine), "No newline");
        var lines = input.Split(new string[] { Environment.NewLine }, StringSplitOptions.None);
        Assert(lines.Count() == 2, "Too many inputs");
        Assert(2 <= lines[0].Count(), "|S| < 2");
        Assert(lines[0].Count() <= 10, "|S| > 10");
        Assert(lines[0].All(c => ('a' <= c && c <= 'z')), "Invalid character");
        return lines[0];
    }

    static string Solve(string s)
    {
        var lasts = s.Substring(s.Length - 2);
        if (lasts == "ai") return s.Substring(0, s.Length - 2) + lasts.ToUpper();
        else return s + "-AI";
    }

    static void Main()
    {
        using (var sr = new StreamReader(Console.OpenStandardInput()))
        {
            var rawInput = sr.ReadToEnd();
            var s = GetCheckedInput(rawInput);
            Console.WriteLine(Solve(s));
        }
    }
}
0