結果

問題 No.225 文字列変更(medium)
ユーザー kotatsugamekotatsugame
提出日時 2020-02-28 06:41:32
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 7 ms / 5,000 ms
コード長 456 bytes
コンパイル時間 825 ms
コンパイル使用メモリ 68,064 KB
実行使用メモリ 7,552 KB
最終ジャッジ日時 2024-04-21 17:25:27
合計ジャッジ時間 1,380 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 4 ms
5,248 KB
testcase_01 AC 6 ms
7,552 KB
testcase_02 AC 1 ms
5,376 KB
testcase_03 AC 2 ms
5,376 KB
testcase_04 AC 1 ms
5,376 KB
testcase_05 AC 2 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 2 ms
5,376 KB
testcase_09 AC 1 ms
5,376 KB
testcase_10 AC 1 ms
5,376 KB
testcase_11 AC 2 ms
5,376 KB
testcase_12 AC 6 ms
7,168 KB
testcase_13 AC 7 ms
7,424 KB
testcase_14 AC 6 ms
7,424 KB
testcase_15 AC 6 ms
7,168 KB
testcase_16 AC 7 ms
7,424 KB
testcase_17 AC 7 ms
7,168 KB
testcase_18 AC 6 ms
7,040 KB
testcase_19 AC 6 ms
7,168 KB
testcase_20 AC 7 ms
7,168 KB
testcase_21 AC 7 ms
7,168 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp:7:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
    7 | main()
      | ^~~~

ソースコード

diff #

#include<iostream>
#include<algorithm>
using namespace std;
int N,M;
string s,t;
int dp[1010][1010];
main()
{
	cin>>N>>M>>s>>t;
	for(int i=0;i<=N;i++)for(int j=0;j<=M;j++)dp[i][j]=1145141919;
	dp[0][0]=0;
	for(int i=0;i<=N;i++)for(int j=0;j<=M;j++)
	{
		if(i<N&&j<M)
		{
			dp[i+1][j+1]=min(dp[i+1][j+1],dp[i][j]+(s[i]!=t[j]));
		}
		if(i<N)dp[i+1][j]=min(dp[i+1][j],dp[i][j]+1);
		if(j<M)dp[i][j+1]=min(dp[i][j+1],dp[i][j]+1);
	}
	cout<<dp[N][M]<<endl;
}
0