結果
問題 | No.225 文字列変更(medium) |
ユーザー |
![]() |
提出日時 | 2019-01-09 20:23:36 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 8 ms / 5,000 ms |
コード長 | 547 bytes |
コンパイル時間 | 1,524 ms |
コンパイル使用メモリ | 167,496 KB |
実行使用メモリ | 7,168 KB |
最終ジャッジ日時 | 2024-11-24 00:59:45 |
合計ジャッジ時間 | 2,336 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type] 7 | main(){ | ^~~~
ソースコード
#include<bits/stdc++.h>#define rep(i,a,b) for(int i=int(a);i<int(b);++i)using namespace std;typedef long long ll;int INF = (1LL << 30) - 1;int MOD = 1e9+7;main(){int N,M;string S,T;cin >> N >> M >> S >> T;int dp[N+1][M+1] = {};rep(i,0,N+1)dp[i][0] = i;rep(i,0,M+1)dp[0][i] = i;rep(i,1,N+1)rep(j,1,M+1){int cost = !(S[i-1] == T[j-1]);dp[i][j] = min({dp[i-1][j] + 1,dp[i][j-1] + 1,dp[i-1][j-1] + cost});}cout << dp[N][M] << endl;}