結果

問題 No.2000 Distanced Characters
ユーザー 👑 kakel-sankakel-san
提出日時 2022-09-04 09:23:21
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 158 ms / 2,000 ms
コード長 1,623 bytes
コンパイル時間 971 ms
コンパイル使用メモリ 68,400 KB
実行使用メモリ 47,088 KB
最終ジャッジ日時 2023-08-11 17:22:56
合計ジャッジ時間 3,798 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 69 ms
23,864 KB
testcase_01 AC 69 ms
21,928 KB
testcase_02 AC 69 ms
23,960 KB
testcase_03 AC 69 ms
21,856 KB
testcase_04 AC 70 ms
23,944 KB
testcase_05 AC 70 ms
23,972 KB
testcase_06 AC 69 ms
21,848 KB
testcase_07 AC 70 ms
21,896 KB
testcase_08 AC 155 ms
47,088 KB
testcase_09 AC 158 ms
46,928 KB
testcase_10 AC 157 ms
46,940 KB
testcase_11 AC 157 ms
46,876 KB
testcase_12 AC 120 ms
33,200 KB
testcase_13 AC 117 ms
32,480 KB
testcase_14 AC 116 ms
32,980 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(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