結果
問題 |
No.225 文字列変更(medium)
|
ユーザー |
|
提出日時 | 2021-08-17 11:28:09 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 834 bytes |
コンパイル時間 | 1,854 ms |
コンパイル使用メモリ | 172,448 KB |
実行使用メモリ | 10,880 KB |
最終ジャッジ日時 | 2024-10-10 08:10:42 |
合計ジャッジ時間 | 2,759 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 17 WA * 5 |
ソースコード
#include <bits/stdc++.h> using namespace std; #define rep(i, n) for(int i = 0; i < (int)n; ++i) using ll = long long; const ll INF = 1LL<<60; template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;} template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;} int main() { int n, m; cin >> n >> m; string S, T; cin >> S >> T; vector<vector<ll>> dp(S.size()+1, vector<ll>(T.size()+1, INF)); dp[0][0] = 0; rep(i, S.size()) rep(j, T.size()) { if (S[i] == T[j]) chmin(dp[i+1][j+1], dp[i][j]); // copy chmin(dp[i+1][j+1], dp[i][j] + 1); // replace chmin(dp[i+1][j+1], dp[i][j+1] + 1); // delete chmin(dp[i+1][j+1], dp[i+1][j] + 1); // insert } cout << dp[S.size()][T.size()] << endl; return 0; }