結果

問題 No.1439 Let's Compare!!!!
ユーザー siman
提出日時 2021-04-01 19:45:26
言語 Ruby
(3.4.1)
結果
TLE  
実行時間 -
コード長 731 bytes
コンパイル時間 350 ms
コンパイル使用メモリ 7,424 KB
実行使用メモリ 64,640 KB
最終ジャッジ日時 2024-12-18 00:46:54
合計ジャッジ時間 25,182 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 8 RE * 2 TLE * 7
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

N = gets.to_i
S = gets.chomp
T = gets.chomp
Q = gets.to_i
state = S <=> T
idx_list = [*0..N]

nums = Array.new(N) { Array.new(2, 0) }
N.times do |i|
  nums[i][0] = S[i].to_i
  nums[i][1] = T[i].to_i
end

Q.times do
  c, x, y = gets.chomp.split
  x = x.to_i - 1
  y = y.to_i

  idx = idx_list.bsearch_index { |i| i > x }

  if idx.nil?
    idx_list << x
  else
    idx_list.insert(idx, x)
  end

  if c == 'S'
    nums[x][0] = y
  else
    nums[x][1] = y
  end

  until idx_list.empty?
    i = idx_list.first

    state = nums[i][0] <=> nums[i][1]
    break if state != 0

    idx_list.shift
  end

  if idx_list.empty?
    state = 0
  end

  case state
  when -1
    puts '<'
  when 0
    puts '=='
  when 1
    puts '>'
  end
end
0