結果
問題 | No.606 カラフルタイル |
ユーザー |
|
提出日時 | 2017-12-06 00:18:38 |
言語 | D (dmd 2.109.1) |
結果 |
AC
|
実行時間 | 86 ms / 2,000 ms |
コード長 | 1,780 bytes |
コンパイル時間 | 1,911 ms |
コンパイル使用メモリ | 155,504 KB |
実行使用メモリ | 6,948 KB |
最終ジャッジ日時 | 2024-06-12 22:48:08 |
合計ジャッジ時間 | 4,409 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
ソースコード
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);}}}