結果

問題 No.2209 Flip and Reverse
ユーザー simansiman
提出日時 2023-02-11 07:30:22
言語 Ruby
(3.3.0)
結果
AC  
実行時間 797 ms / 2,000 ms
コード長 381 bytes
コンパイル時間 369 ms
コンパイル使用メモリ 11,264 KB
実行使用メモリ 19,652 KB
最終ジャッジ日時 2023-09-22 06:37:31
合計ジャッジ時間 20,361 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 83 ms
15,092 KB
testcase_01 AC 81 ms
15,192 KB
testcase_02 AC 81 ms
15,124 KB
testcase_03 AC 81 ms
15,100 KB
testcase_04 AC 81 ms
15,208 KB
testcase_05 AC 80 ms
15,280 KB
testcase_06 AC 80 ms
15,124 KB
testcase_07 AC 82 ms
15,116 KB
testcase_08 AC 779 ms
19,588 KB
testcase_09 AC 80 ms
15,096 KB
testcase_10 AC 81 ms
15,276 KB
testcase_11 AC 83 ms
15,128 KB
testcase_12 AC 82 ms
15,028 KB
testcase_13 AC 82 ms
15,164 KB
testcase_14 AC 786 ms
19,448 KB
testcase_15 AC 789 ms
19,496 KB
testcase_16 AC 788 ms
19,652 KB
testcase_17 AC 790 ms
19,496 KB
testcase_18 AC 789 ms
19,536 KB
testcase_19 AC 786 ms
19,388 KB
testcase_20 AC 790 ms
19,252 KB
testcase_21 AC 794 ms
19,416 KB
testcase_22 AC 790 ms
19,508 KB
testcase_23 AC 797 ms
19,376 KB
testcase_24 AC 793 ms
19,476 KB
testcase_25 AC 789 ms
19,288 KB
testcase_26 AC 793 ms
19,580 KB
testcase_27 AC 790 ms
19,316 KB
testcase_28 AC 777 ms
19,488 KB
testcase_29 AC 778 ms
19,452 KB
testcase_30 AC 775 ms
19,384 KB
testcase_31 AC 781 ms
19,440 KB
testcase_32 AC 784 ms
19,616 KB
testcase_33 AC 780 ms
19,604 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.rb:5: warning: assigned but unused variable - ans
Syntax OK

ソースコード

diff #

N = gets.to_i
S = gets.chomp
T = gets.chomp

ans = Float::INFINITY

def f
  diff = 0

  N.times do |i|
    diff += 1 if S[i] != T[i]
  end

  if diff.even?
    diff
  else
    Float::INFINITY
  end
end

def g
  diff = 0


  N.times do |i|
    j = N - (i + 1)

    diff += 1 if S[i] != T[j]
  end

  if diff.even?
    Float::INFINITY
  else
    diff
  end
end


puts [f(), g()].min
0