結果

問題 No.606 カラフルタイル
ユーザー 👑 obakyanobakyan
提出日時 2019-06-07 23:59:19
言語 Lua
(LuaJit 2.1.1696795921)
結果
AC  
実行時間 125 ms / 2,000 ms
コード長 831 bytes
コンパイル時間 72 ms
コンパイル使用メモリ 6,816 KB
実行使用メモリ 13,716 KB
最終ジャッジ日時 2024-04-15 19:27:01
合計ジャッジ時間 3,114 ms
ジャッジサーバーID
(参考情報)
judge1 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 1 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 1 ms
5,376 KB
testcase_08 AC 1 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 2 ms
5,376 KB
testcase_13 AC 7 ms
5,376 KB
testcase_14 AC 4 ms
5,376 KB
testcase_15 AC 4 ms
5,376 KB
testcase_16 AC 49 ms
6,144 KB
testcase_17 AC 116 ms
12,696 KB
testcase_18 AC 79 ms
9,624 KB
testcase_19 AC 78 ms
9,496 KB
testcase_20 AC 125 ms
13,456 KB
testcase_21 AC 91 ms
10,780 KB
testcase_22 AC 90 ms
10,792 KB
testcase_23 AC 109 ms
11,968 KB
testcase_24 AC 118 ms
13,580 KB
testcase_25 AC 63 ms
9,088 KB
testcase_26 AC 104 ms
13,004 KB
testcase_27 AC 117 ms
13,716 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

local n, k, q = io.read("*n", "*n", "*n", "*l")
local ta, tb, tc = {}, {}, {}
for i = 1, q do
  local a, b, c = io.read():match("(%w) (%d+) (%d+)")
  ta[i], tb[i], tc[i] = (a == "R"), tonumber(b), tonumber(c)
end
local rowused, colused = {}, {}
for i = 1, n do
  rowused[i], colused[i] = false, false
end
local rowrem, colrem = n, n

local color = {}
for i = 1, k do color[i] = 0 end
for i = q, 1, -1 do
  if ta[i] then
    if not rowused[tb[i]] then
      rowused[tb[i]] = true
      color[tc[i]] = color[tc[i]] + colrem
      rowrem = rowrem - 1
    end
  else
    if not colused[tb[i]] then
      colused[tb[i]] = true
      color[tc[i]] = color[tc[i]] + rowrem
      colrem = colrem - 1
    end
  end
end
for i = 1, n do
  if not rowused[i] then
    color[1] = color[1] + colrem
  end
end
for i = 1, k do
  print(color[i])
end
0