結果

問題 No.225 文字列変更(medium)
ユーザー tottoripapertottoripaper
提出日時 2015-06-13 20:45:17
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 481 bytes
コンパイル時間 471 ms
コンパイル使用メモリ 60,112 KB
実行使用メモリ 7,416 KB
最終ジャッジ日時 2023-09-21 01:08:20
合計ジャッジ時間 1,452 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 WA -
testcase_06 AC 2 ms
4,376 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 6 ms
6,848 KB
testcase_13 AC 7 ms
7,128 KB
testcase_14 AC 7 ms
7,140 KB
testcase_15 AC 7 ms
7,044 KB
testcase_16 AC 7 ms
7,232 KB
testcase_17 AC 7 ms
6,864 KB
testcase_18 AC 7 ms
6,928 KB
testcase_19 AC 7 ms
7,012 KB
testcase_20 AC 6 ms
6,976 KB
testcase_21 AC 6 ms
7,096 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <algorithm>

int N, M;
std::string S, T;
int dp[1001][1001];

int main(){
    std::cin >> N >> M;
    std::cin >> S >> T;

    for(int i=1;i<N;i++){
        dp[i][0] = i;
    }

    for(int i=1;i<M;i++){
        dp[0][i] = i;
    }

    for(int i=1;i<=N;i++){
        for(int j=1;j<=M;j++){
            dp[i][j] = std::min({dp[i-1][j] + 1, dp[i][j-1] + 1, dp[i-1][j-1] + (S[i-1] != T[j-1])});
        }
    }

    std::cout << dp[N][M] << std::endl;
}
0