結果

問題 No.606 カラフルタイル
ユーザー simansiman
提出日時 2022-04-03 02:43:02
言語 Ruby
(3.3.0)
結果
AC  
実行時間 429 ms / 2,000 ms
コード長 587 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 47,744 KB
最終ジャッジ日時 2024-05-02 01:37:41
合計ジャッジ時間 7,760 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 79 ms
12,160 KB
testcase_01 AC 77 ms
12,160 KB
testcase_02 AC 79 ms
12,032 KB
testcase_03 AC 78 ms
12,160 KB
testcase_04 AC 78 ms
12,160 KB
testcase_05 AC 78 ms
12,288 KB
testcase_06 AC 76 ms
12,160 KB
testcase_07 AC 77 ms
12,288 KB
testcase_08 AC 76 ms
12,288 KB
testcase_09 AC 75 ms
12,160 KB
testcase_10 AC 77 ms
12,288 KB
testcase_11 AC 76 ms
12,160 KB
testcase_12 AC 76 ms
12,160 KB
testcase_13 AC 97 ms
14,080 KB
testcase_14 AC 79 ms
12,160 KB
testcase_15 AC 80 ms
12,416 KB
testcase_16 AC 277 ms
36,608 KB
testcase_17 AC 429 ms
45,824 KB
testcase_18 AC 324 ms
41,856 KB
testcase_19 AC 327 ms
40,832 KB
testcase_20 AC 420 ms
44,032 KB
testcase_21 AC 316 ms
40,192 KB
testcase_22 AC 309 ms
40,192 KB
testcase_23 AC 321 ms
39,296 KB
testcase_24 AC 380 ms
42,624 KB
testcase_25 AC 368 ms
38,016 KB
testcase_26 AC 429 ms
47,744 KB
testcase_27 AC 423 ms
46,720 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N, K, Q = gets.split.map(&:to_i)
query_list = Q.times.map { gets.chomp.split }
counter = Hash.new(0)
row_c = 0
col_c = 0
row_visited = Hash.new(false)
col_visited = Hash.new(false)

query_list.reverse_each do |a, b, c|
  b = b.to_i
  c = c.to_i

  next if row_visited[b] && a == 'R'
  next if col_visited[b] && a == 'C'

  if a == 'C'
    counter[c] += N - row_c if c != 1
    col_visited[b] = true
    col_c += 1
  else
    counter[c] += N - col_c if c != 1
    row_visited[b] = true
    row_c += 1
  end
end

counter[1] = N * N - counter.values.sum

puts (1..K).map { |c| counter[c] }
0