結果

問題 No.225 文字列変更(medium)
ユーザー TwizzTwizz
提出日時 2017-06-10 10:24:05
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 673 bytes
コンパイル時間 1,337 ms
コンパイル使用メモリ 160,544 KB
実行使用メモリ 7,560 KB
最終ジャッジ日時 2023-10-24 20:23:45
合計ジャッジ時間 2,064 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 AC 2 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:22:45: warning: overflow in conversion from ‘ll’ {aka ‘long long int’} to ‘int’ changes value from ‘100000000000’ to ‘1215752192’ [-Woverflow]
   22 |         REP(i, n + 1)REP(j, m + 1)d[i][j] = mod;
      |                                             ^~~

ソースコード

diff #

#include"bits/stdc++.h"

//#include<bits/stdc++.h>
using namespace std;
#define print(x) cout<<x<<endl;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a) for(int i=0;i<a;i++)
typedef long long ll;
typedef pair<int, int> PI;
typedef pair<int, PI> V;
typedef vector<int> VE;
const ll mod = 100000000000;

int n, m;
string s, t;
int d[1002][1002];

int main() {
	cin >> n >> m;
	cin >> s;
	cin >> t;
	REP(i, n + 1)REP(j, m + 1)d[i][j] = mod;
	REP(i, n+1)d[i][0] = i;
	REP(i, m+1)d[0][i] = i;
	rep(i,1, n+1)rep(j,1, m+1) {
		int cost = s[i] == t[j] ? 0 : 1;
		d[i][j] = min(d[i - 1][j] + 1, min(d[i][j - 1] + 1, d[i - 1][i - 1] + cost));
	}
	print(d[n][m]);
	return 0;
}
0