結果
問題 | No.225 文字列変更(medium) |
ユーザー |
![]() |
提出日時 | 2017-06-10 10:53:03 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
AC
|
実行時間 | 6 ms / 5,000 ms |
コード長 | 693 bytes |
コンパイル時間 | 1,313 ms |
コンパイル使用メモリ | 159,344 KB |
実行使用メモリ | 7,400 KB |
最終ジャッジ日時 | 2024-09-24 15:32:13 |
合計ジャッジ時間 | 2,242 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 22 |
コンパイルメッセージ
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; | ^~~
ソースコード
#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;}