結果

問題 No.225 文字列変更(medium)
ユーザー kuroi_13kuroi_13
提出日時 2017-02-27 09:23:07
言語 Perl
(5.38.2)
結果
AC  
実行時間 751 ms / 5,000 ms
コード長 498 bytes
コンパイル時間 517 ms
コンパイル使用メモリ 5,296 KB
実行使用メモリ 39,336 KB
最終ジャッジ日時 2023-09-02 12:38:02
合計ジャッジ時間 9,629 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 294 ms
18,112 KB
testcase_01 AC 496 ms
25,472 KB
testcase_02 AC 5 ms
4,868 KB
testcase_03 AC 5 ms
5,028 KB
testcase_04 AC 5 ms
4,912 KB
testcase_05 AC 5 ms
4,952 KB
testcase_06 AC 5 ms
4,952 KB
testcase_07 AC 5 ms
4,916 KB
testcase_08 AC 5 ms
5,024 KB
testcase_09 AC 5 ms
4,880 KB
testcase_10 AC 6 ms
4,988 KB
testcase_11 AC 5 ms
5,036 KB
testcase_12 AC 695 ms
36,964 KB
testcase_13 AC 751 ms
39,336 KB
testcase_14 AC 731 ms
38,812 KB
testcase_15 AC 709 ms
37,260 KB
testcase_16 AC 712 ms
38,220 KB
testcase_17 AC 711 ms
37,044 KB
testcase_18 AC 684 ms
36,452 KB
testcase_19 AC 702 ms
37,688 KB
testcase_20 AC 667 ms
35,940 KB
testcase_21 AC 704 ms
37,516 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

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];
0