結果
問題 | No.225 文字列変更(medium) |
ユーザー | ふーらくたる |
提出日時 | 2016-09-23 18:17:41 |
言語 | C++11 (gcc 11.4.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 814 bytes |
コンパイル時間 | 452 ms |
コンパイル使用メモリ | 56,044 KB |
実行使用メモリ | 7,424 KB |
最終ジャッジ日時 | 2024-04-28 22:38:01 |
合計ジャッジ時間 | 1,344 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | WA | - |
testcase_01 | WA | - |
testcase_02 | AC | 5 ms
7,424 KB |
testcase_03 | AC | 4 ms
7,424 KB |
testcase_04 | AC | 4 ms
7,424 KB |
testcase_05 | WA | - |
testcase_06 | AC | 4 ms
7,404 KB |
testcase_07 | WA | - |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | AC | 4 ms
7,396 KB |
testcase_12 | AC | 7 ms
7,344 KB |
testcase_13 | AC | 7 ms
7,296 KB |
testcase_14 | AC | 7 ms
7,424 KB |
testcase_15 | AC | 7 ms
7,424 KB |
testcase_16 | AC | 7 ms
7,296 KB |
testcase_17 | AC | 7 ms
7,372 KB |
testcase_18 | AC | 7 ms
7,424 KB |
testcase_19 | AC | 7 ms
7,424 KB |
testcase_20 | AC | 7 ms
7,424 KB |
testcase_21 | AC | 7 ms
7,420 KB |
ソースコード
#include <iostream> using namespace std; const int MAX_N = 1010; const int MAX_M = 1010; const int INF = (1 << 28); int dp[MAX_N][MAX_M]; int main() { int n, m; string s, t; cin >> n >> m; cin >> s >> t; fill((int* )dp, (int* )(dp + MAX_N), INF); dp[0][0] = 0; dp[n][0] = 0; dp[0][m] = 0; for (int i = 0; i <= n; i++) { for (int j = 0; j <= m; j++) { if (i - 1 >= 0) { dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1); } if (j - 1 >= 0) { dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1); } if (i - 1 >= 0 && j - 1 >= 0) { dp[i][j] = min(dp[i][j], dp[i - 1][j - 1] + (s[i - 1] == t[j - 1] ? 0 : 1)); } } } cout << dp[n][m] << endl; return 0; }