結果

問題 No.606 カラフルタイル
ユーザー ikdikd
提出日時 2017-12-06 00:32:13
言語 D
(dmd 2.107.1)
結果
AC  
実行時間 92 ms / 2,000 ms
コード長 832 bytes
コンパイル時間 1,767 ms
コンパイル使用メモリ 142,200 KB
実行使用メモリ 6,860 KB
最終ジャッジ日時 2023-09-03 17:13:42
合計ジャッジ時間 4,101 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,376 KB
testcase_01 AC 1 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 2 ms
4,376 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,376 KB
testcase_10 AC 1 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,380 KB
testcase_13 AC 8 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 2 ms
4,380 KB
testcase_16 AC 58 ms
4,520 KB
testcase_17 AC 92 ms
5,572 KB
testcase_18 AC 61 ms
4,832 KB
testcase_19 AC 60 ms
5,752 KB
testcase_20 AC 91 ms
5,624 KB
testcase_21 AC 62 ms
4,784 KB
testcase_22 AC 63 ms
6,332 KB
testcase_23 AC 70 ms
5,084 KB
testcase_24 AC 85 ms
5,364 KB
testcase_25 AC 85 ms
6,860 KB
testcase_26 AC 92 ms
5,776 KB
testcase_27 AC 91 ms
6,632 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

void main(){
  import std.stdio, std.string, std.conv, std.algorithm;

  long n; int k, q; rd(n, k, q);
  auto a=new char[](q), b=new int[](q), c=new int[](q);
  foreach(i; 0..q){
    rd(a[i], b[i], c[i]);
    b[i]--; c[i]--;
  }

  auto cnt=new long[](k);
  auto used=new bool[][](2, n);
  auto num=new long[](2);
  foreach_reverse(i; 0..q){
    auto j=(a[i]=='R'?0:1);
    if(used[j][b[i]]) continue;
    used[j][b[i]]=true;
    cnt[c[i]]+=(n-num[j^1]);
    num[j]++;
  }

  cnt[0]=n*n-reduce!((r, e)=>(r+e))(0L, cnt[1..$]);
  writefln("%(%s\n%)", cnt);
}

void rd(T...)(ref T x){
  import std.stdio, std.string, std.conv;
  auto l=readln.split;
  assert(l.length==x.length);
  foreach(i, ref e; x){
    e=l[i].to!(typeof(e));
  }
}
void wr(T...)(T x){
  import std.stdio;
  foreach(e; x) stderr.write(e, " ");
  stderr.writeln;
}
0