結果

問題 No.225 文字列変更(medium)
ユーザー koyopro
提出日時 2015-10-12 01:24:31
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 759 bytes
コンパイル時間 2,373 ms
コンパイル使用メモリ 177,764 KB
実行使用メモリ 552,576 KB
最終ジャッジ日時 2024-07-21 07:08:00
合計ジャッジ時間 19,412 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 3 WA * 16 MLE * 3
権限があれば一括ダウンロードができます

ソースコード

diff #

#include "bits/stdc++.h"
using namespace std;

#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)

int N,M;
string S, T;
int cost(string s, string t) {
    int ret = 0;
    REP(i,s.size()) ret += (s[i] != t[i]);
    return ret + abs((int)(s.size() - t.size()));
}
signed main()
{
    cin >> N >> M >> S >> T;
    map<string, map<string, int> > dp;
    dp[""][""] = 0;
    RREP(i,N) {
        string s = S.substr(i);
        string s1 = (s.size() > 1 ? s.substr(1) : "");
        RREP(j,M) {
            string t = T.substr(j);
            string t1 = (t.size() > 1 ? t.substr(1) : "");
            dp[s][t] = min(dp[s1][t1] + (s[0] != t[1]), dp[s1][t] + 1);
        }
    }
    cout << dp[S][T] << endl;
    return 0;
}
0