結果
問題 | No.225 文字列変更(medium) |
ユーザー |
![]() |
提出日時 | 2017-02-27 09:23:07 |
言語 | Perl (5.40.0) |
結果 |
AC
|
実行時間 | 679 ms / 5,000 ms |
コード長 | 498 bytes |
コンパイル時間 | 151 ms |
コンパイル使用メモリ | 6,816 KB |
実行使用メモリ | 40,448 KB |
最終ジャッジ日時 | 2024-06-11 19:18:56 |
合計ジャッジ時間 | 8,260 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
Main.pl syntax OK
ソースコード
use strict;use warnings;my($len1, $len2) = split ' ', <STDIN>;my @ar1 = split('', <STDIN>);my @ar2 = split('', <STDIN>);my @dist;for(0..$len1){$dist[$_][0] = $_;}for(0..$len2){$dist[0][$_] = $_;}my $rep;my $ref;my @costs;for my $i (1..$len1){for my $j (1..$len2){$rep = $ar1[$i-1] eq $ar2[$j-1] ? 0 : 1;@costs = ($dist[$i-1][$j] + 1, $dist[$i][$j-1] + 1, $dist[$i-1][$j-1] + $rep);$dist[$i][$j] = (sort {$a <=> $b} @costs)[0];}}print $dist[$len1][$len2];