結果

問題 No.606 カラフルタイル
ユーザー nanaenanae
提出日時 2017-12-06 00:18:38
言語 D
(dmd 2.106.1)
結果
AC  
実行時間 95 ms / 2,000 ms
コード長 1,780 bytes
コンパイル時間 2,566 ms
コンパイル使用メモリ 151,772 KB
実行使用メモリ 7,100 KB
最終ジャッジ日時 2023-09-03 17:12:54
合計ジャッジ時間 5,930 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,380 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 2 ms
4,380 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,380 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 2 ms
4,376 KB
testcase_11 AC 2 ms
4,380 KB
testcase_12 AC 1 ms
4,376 KB
testcase_13 AC 8 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 60 ms
5,964 KB
testcase_17 AC 93 ms
7,100 KB
testcase_18 AC 63 ms
6,540 KB
testcase_19 AC 62 ms
6,196 KB
testcase_20 AC 92 ms
6,060 KB
testcase_21 AC 64 ms
5,044 KB
testcase_22 AC 64 ms
6,476 KB
testcase_23 AC 73 ms
6,320 KB
testcase_24 AC 85 ms
6,012 KB
testcase_25 AC 85 ms
6,028 KB
testcase_26 AC 95 ms
5,936 KB
testcase_27 AC 93 ms
6,208 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import std.stdio, std.string, std.conv, std.algorithm, std.numeric;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

alias Nuru = Tuple!(char, "r", int, "x", int, "col");

void main() {
    int n, k, q;
    scan(n, k, q);

    auto cmd = new Nuru[](q);

    foreach_reverse (i ; 0 .. q) {
        char ai;
        int bi, ci;
        scan(ai, bi, ci);
        cmd[i] = Nuru(ai, bi - 1, ci - 1);
    }

    int rn, cn;
    auto rb = new bool[](n);
    auto cb = new bool[](n);
    auto col = new long[](k);

    long s = 1L * n * n;

    foreach (i, cm ; cmd) {
        if (cm.r == 'R') {
            if (rb[cm.x]) continue;
            rb[cm.x] = 1;
            col[cm.col] += n - cn;
            rn++;
            s -= n - cn;
        }
        else {
            if (cb[cm.x]) continue;
            cb[cm.x] = 1;
            col[cm.col] += n - rn;
            cn++;
            s -= n - rn;
        }
    }

    col[0] += s;

    writefln("%(%s\n%)", col);

}

int[] manacher(string s) {
    int[] r = new int[](s.length);

    int i, j;

    while (i < s.length) {
        while (i-j >= 0 && i+j < s.length && s[i-j] == s[i+j]) j++;
        r[i] = j;
        int k = 1;
        while (i-k >= 0 && i+k < s.length && k+r[i-k] < j) {
            r[i+k] = r[i-k];
            k++;
        }
        i += k;
        j -= k;
    }

    return r;
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}
0