結果

問題 No.2226 Hello, Forgotten World!
ユーザー 👑 kakel-sankakel-san
提出日時 2023-02-24 21:39:42
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 487 ms / 2,000 ms
コード長 1,553 bytes
コンパイル時間 2,239 ms
コンパイル使用メモリ 65,804 KB
実行使用メモリ 39,004 KB
最終ジャッジ日時 2023-10-11 05:59:22
合計ジャッジ時間 3,442 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 57 ms
18,560 KB
testcase_01 AC 487 ms
39,004 KB
testcase_02 AC 124 ms
27,968 KB
testcase_03 AC 119 ms
25,712 KB
testcase_04 AC 87 ms
23,464 KB
testcase_05 AC 122 ms
27,872 KB
testcase_06 AC 96 ms
23,656 KB
testcase_07 AC 105 ms
27,720 KB
testcase_08 AC 85 ms
23,412 KB
testcase_09 AC 106 ms
27,760 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static int NN => int.Parse(ReadLine());
    static int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    static int[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var t = NN;
        var ans = new string[t];
        for (var u = 0; u < t; ++u)
        {
            var n = NN;
            var s = ReadLine();
            ans[u] = Hello(n, s);
        }
        WriteLine(string.Join("\n", ans));
    }
    static string Hello(int n, string s)
    {
        var list = new List<string>();
        var str = "helloworld";
        for (var i = 0; i + 10 <= s.Length; ++i)
        {
            var flg = true;
            var c = s.ToCharArray();
            for (var j = 0; j < 10; ++j)
            {
                if (c[i + j] == '?') c[i + j] = str[j];
                else if (c[i + j] != str[j])
                {
                    flg = false;
                    break;
                }
            }
            if (!flg) continue;
            for (var j = 0; j < c.Length; ++j)
            {
                if (c[j] == '?') c[j] = 'a';
            }
            list.Add(string.Concat(c));
        }
        if (list.Count == 0)
        {
            return "-1";
        }
        list.Sort();
        return list[0];
    }
}
0