結果

問題 No.606 カラフルタイル
ユーザー YosukeKawadaYosukeKawada
提出日時 2017-12-18 11:18:44
言語 Ruby
(3.3.0)
結果
AC  
実行時間 1,287 ms / 2,000 ms
コード長 883 bytes
コンパイル時間 63 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 29,312 KB
最終ジャッジ日時 2024-05-09 11:18:28
合計ジャッジ時間 15,325 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 90 ms
12,288 KB
testcase_01 AC 97 ms
12,416 KB
testcase_02 AC 646 ms
24,960 KB
testcase_03 AC 88 ms
12,288 KB
testcase_04 AC 88 ms
12,288 KB
testcase_05 AC 88 ms
12,288 KB
testcase_06 AC 89 ms
12,160 KB
testcase_07 AC 90 ms
12,160 KB
testcase_08 AC 90 ms
12,160 KB
testcase_09 AC 91 ms
12,288 KB
testcase_10 AC 91 ms
12,160 KB
testcase_11 AC 141 ms
13,056 KB
testcase_12 AC 90 ms
12,160 KB
testcase_13 AC 107 ms
12,288 KB
testcase_14 AC 661 ms
24,832 KB
testcase_15 AC 101 ms
12,416 KB
testcase_16 AC 226 ms
12,416 KB
testcase_17 AC 687 ms
21,888 KB
testcase_18 AC 575 ms
21,504 KB
testcase_19 AC 545 ms
20,352 KB
testcase_20 AC 1,287 ms
29,056 KB
testcase_21 AC 1,103 ms
29,184 KB
testcase_22 AC 1,107 ms
29,184 KB
testcase_23 AC 1,048 ms
29,312 KB
testcase_24 AC 1,043 ms
29,184 KB
testcase_25 AC 884 ms
29,056 KB
testcase_26 AC 1,050 ms
29,056 KB
testcase_27 AC 967 ms
29,184 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:37: warning: assigned but unused variable - color
Syntax OK

ソースコード

diff #

def readl
  $stdin.gets.split(" ")
end

N,K,Q = readl.map{ |r| r.to_i }

rows = (0...N).map{ [-1,1] }
cols = (0...N).map{ [-2,1] }

#p rows
#p cols

Q.times do |i|
  a,b,c = readl
  b = b.to_i
  c = c.to_i
  colorpair = [i,c]
  case a
  when "R"
    rows[b-1] = colorpair
  when "C"
    cols[b-1] = colorpair
  end
end

#p rows
#p cols

rows = rows.sort{ |a,b| a[0] <=> b[0] }
cols = cols.sort{ |a,b| a[0] <=> b[0] }

#p rows
#p cols

def count_wins(item, arr)
  i = item[0]
  color = item[1]

  # b-search

  mi,ma = 0,arr.size-1

  j = (mi+ma)/2
  if i <arr[j][0]
    ma = i
  else
    mi = i
  end

  #p [item, arr]
  if j = arr.bsearch_index{ |b| i < b[0] }
    j
  else
    arr.size
  end
end

color_count = (0...K).map{ 0 }

rows.each do |s|
  color_count[s[1]-1] += count_wins(s, cols)
end

cols.each do |s|
  color_count[s[1]-1] += count_wins(s, rows)
end


puts color_count
0