結果

問題 No.197 手品
ユーザー gemmaro
提出日時 2020-11-06 00:27:44
言語 Ruby
(3.4.1)
結果
AC  
実行時間 92 ms / 1,000 ms
コード長 473 bytes
コンパイル時間 89 ms
コンパイル使用メモリ 7,552 KB
実行使用メモリ 12,288 KB
最終ジャッジ日時 2024-07-22 11:37:55
合計ジャッジ時間 5,631 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 43
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

# frozen_string_literal: true

def solve
  solve_ ? 'SUCCESS' : 'FAILURE'
end

def solve_
  b = S_BEFORE.bools
  a = S_AFTER.bools

  return true if a.sum != b.sum
  return false if b.same

  case N
  when 0 then b != a
  when 1
    b == (b[0] == b[2] ? a : a.reverse)
  end
end

class Array
  def same
    uniq.size == 1
  end
end

class String
  def bools
    chars.map { _1 == 'o' ? 0 : 1 }
  end
end

S_BEFORE = gets.chomp
N = gets.to_i
S_AFTER = gets.chomp

puts solve
0