結果

問題 No.2000 Distanced Characters
ユーザー kokatsukokatsu
提出日時 2022-07-08 21:55:30
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 239 ms / 2,000 ms
コード長 807 bytes
コンパイル時間 2,412 ms
コンパイル使用メモリ 210,620 KB
実行使用メモリ 8,104 KB
最終ジャッジ日時 2023-09-04 17:42:06
合計ジャッジ時間 4,488 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 3 ms
4,376 KB
testcase_05 AC 3 ms
4,376 KB
testcase_06 AC 2 ms
4,380 KB
testcase_07 AC 2 ms
4,380 KB
testcase_08 AC 54 ms
4,552 KB
testcase_09 AC 239 ms
5,224 KB
testcase_10 AC 188 ms
6,796 KB
testcase_11 AC 79 ms
8,104 KB
testcase_12 AC 89 ms
4,628 KB
testcase_13 AC 81 ms
4,624 KB
testcase_14 AC 132 ms
4,652 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std;

void main() {
    auto S = readln.chomp;

    int L = 26;
    auto D = new int[][](L);
    foreach (i; 0 .. L) D[i] = readln.chomp.split.to!(int[]);

    auto pos = new int[][](L);
    foreach (i, s; S) {
        pos[s-'a'] ~= i.to!int;
    }

    auto spos = new SortedRange!(int[], "a < b")[](L);
    foreach (i; 0 .. L) {
        spos[i] = pos[i].assumeSorted;
    }

    auto res = new dchar[][](L, L);
    foreach (i; 0 .. L) res[i][] = 'Y';

    foreach (i, s; S) {
        int t = s - 'a';

        foreach (j; 0 .. L) {
            int num = i.to!int + D[t][j];
            auto ub = spos[j].lowerBound(num);
            if (ub.empty) continue;
            if (ub.back <= i) continue;

            res[t][j] = 'N';
        }
    }

    foreach (i; 0 .. L) writefln("%(%c %)", res[i]);
}
0