結果

問題 No.2000 Distanced Characters
ユーザー 👑 kakel-sankakel-san
提出日時 2022-09-04 09:23:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 119 ms / 2,000 ms
コード長 1,623 bytes
コンパイル時間 1,094 ms
コンパイル使用メモリ 109,056 KB
実行使用メモリ 40,064 KB
最終ジャッジ日時 2024-04-29 09:00:42
合計ジャッジ時間 3,033 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
19,200 KB
testcase_01 AC 33 ms
19,200 KB
testcase_02 AC 32 ms
19,072 KB
testcase_03 AC 31 ms
18,944 KB
testcase_04 AC 33 ms
19,072 KB
testcase_05 AC 35 ms
19,456 KB
testcase_06 AC 33 ms
19,328 KB
testcase_07 AC 34 ms
19,240 KB
testcase_08 AC 116 ms
39,808 KB
testcase_09 AC 119 ms
39,680 KB
testcase_10 AC 118 ms
39,680 KB
testcase_11 AC 115 ms
40,064 KB
testcase_12 AC 80 ms
30,464 KB
testcase_13 AC 78 ms
29,696 KB
testcase_14 AC 81 ms
29,952 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 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(int n) => Enumerable.Repeat(0, n).Select(_ => NList).ToArray();
    static void Main()
    {
        var s = ReadLine();
        var map = NArr(26);
        var nextd = new int[26][];
        for (var i = 0; i < nextd.Length; ++i) nextd[i] = Enumerable.Repeat(int.MaxValue / 2, s.Length).ToArray();
        for (var i = s.Length - 2; i >= 0; --i)
        {
            for (var c = 0; c < 26; ++c)
            {
                if (s[i + 1] - 'a' == c) nextd[c][i] = 1;
                else nextd[c][i] = nextd[c][i + 1] + 1;
            }
        }
        var len = new int[26][];
        for (var i = 0; i < len.Length; ++i) len[i] = Enumerable.Repeat(int.MaxValue / 2, 26).ToArray();
        for (var i = 0; i < nextd.Length; ++i)
        {
            for (var j = 0; j < nextd[i].Length; ++j)
            {
                var c = s[j] - 'a';
                len[c][i] = Math.Min(len[c][i], nextd[i][j]);
            }
        }
        var res = new bool[26][];
        for (var i = 0; i < res.Length; ++i)
        {
            res[i] = new bool[26];
            for (var j = 0; j < res[i].Length; ++j)
            {
                if (map[i][j] <= len[i][j]) res[i][j] = true;
            }
        }
        WriteLine(string.Join("\n", res.Select(r => string.Join(" ", r.Select(f => f ? "Y" : "N")))));
    }
}
0