結果
| 問題 |
No.225 文字列変更(medium)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2017-06-29 13:46:49 |
| 言語 | Ruby (3.4.1) |
| 結果 |
AC
|
| 実行時間 | 504 ms / 5,000 ms |
| コード長 | 515 bytes |
| コンパイル時間 | 47 ms |
| コンパイル使用メモリ | 7,552 KB |
| 実行使用メモリ | 19,712 KB |
| 最終ジャッジ日時 | 2024-10-04 16:35:28 |
| 合計ジャッジ時間 | 7,448 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 22 |
コンパイルメッセージ
Syntax OK
ソースコード
def ascan; gets.split.map(&:to_i); end
def scan; gets.to_i; end
def editDistance(str1,str2)
d = Array.new(str1.size+1){Array.new(str2.size+1)}
0.upto(str1.size){|i| d[i][0] = i}
0.upto(str2.size){|j| d[0][j] = j}
1.upto(str1.size){|i|
1.upto(str2.size){|j|
d[i][j] = [d[i][j-1] + 1, d[i-1][j] + 1, d[i-1][j-1] + (str1[i-1] == str2[j-1] ? 0 : 1)].min
}
}
# d.each{|l| puts l*" "}
return d[str1.size][str2.size]
end
gets
p editDistance(gets.chomp, gets.chomp)