結果

問題 No.225 文字列変更(medium)
ユーザー TwizzTwizz
提出日時 2017-06-10 10:53:03
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 6 ms / 5,000 ms
コード長 693 bytes
コンパイル時間 1,644 ms
コンパイル使用メモリ 160,456 KB
実行使用メモリ 7,580 KB
最終ジャッジ日時 2023-10-24 20:25:44
合計ジャッジ時間 2,558 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 5 ms
7,580 KB
testcase_01 AC 5 ms
7,576 KB
testcase_02 AC 3 ms
7,572 KB
testcase_03 AC 3 ms
7,572 KB
testcase_04 AC 4 ms
7,572 KB
testcase_05 AC 3 ms
7,572 KB
testcase_06 AC 3 ms
7,572 KB
testcase_07 AC 3 ms
7,572 KB
testcase_08 AC 3 ms
7,572 KB
testcase_09 AC 3 ms
7,572 KB
testcase_10 AC 3 ms
7,572 KB
testcase_11 AC 3 ms
7,572 KB
testcase_12 AC 6 ms
7,580 KB
testcase_13 AC 6 ms
7,580 KB
testcase_14 AC 6 ms
7,576 KB
testcase_15 AC 6 ms
7,580 KB
testcase_16 AC 6 ms
7,576 KB
testcase_17 AC 5 ms
7,580 KB
testcase_18 AC 6 ms
7,576 KB
testcase_19 AC 5 ms
7,576 KB
testcase_20 AC 5 ms
7,576 KB
testcase_21 AC 6 ms
7,576 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
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, 1002)d[i][0] = d[0][i] = i;
	int cost = 0;
	rep(i,1, n+1)rep(j,1, m+1) {
		if (s[i - 1] == t[j - 1])cost = 0;
		else cost = 1;
		d[i][j] = min(d[i - 1][j] + 1, min(d[i][j - 1] + 1, d[i - 1][j - 1] + cost));
	}
	print(d[n][m]);
	return 0;
}
0