結果
| 問題 | No.225 文字列変更(medium) |
| コンテスト | |
| ユーザー |
tubo28
|
| 提出日時 | 2015-06-17 18:45:47 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0 + boost 1.89.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 612 bytes |
| 記録 | |
| コンパイル時間 | 440 ms |
| コンパイル使用メモリ | 52,948 KB |
| 最終ジャッジ日時 | 2024-11-14 19:04:17 |
| 合計ジャッジ時間 | 799 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
main.cpp:4:31: error: ‘string’ does not name a type; did you mean ‘stdin’?
4 | int LevenshteinDistance(const string& str1, const string& str2){
| ^~~~~~
| stdin
main.cpp:4:51: error: ‘string’ does not name a type; did you mean ‘stdin’?
4 | int LevenshteinDistance(const string& str1, const string& str2){
| ^~~~~~
| stdin
main.cpp: In function ‘int LevenshteinDistance(const int&, const int&)’:
main.cpp:6:19: error: request for member ‘size’ in ‘str1’, which is of non-class type ‘const int’
6 | int l1 = str1.size(), l2 = str2.size();
| ^~~~
main.cpp:8:11: error: ‘l2’ was not declared in this scope; did you mean ‘l1’?
8 | rep(i,l2+1) dp[0][i] = i;
| ^~
main.cpp:3:32: note: in definition of macro ‘rep’
3 | #define rep(i,b) for(int i=0;i<b;i++)
| ^
main.cpp:9:20: error: ‘l2’ was not declared in this scope; did you mean ‘l1’?
9 | rep(i,l1)rep(j,l2){
| ^~
main.cpp:3:32: note: in definition of macro ‘rep’
3 | #define rep(i,b) for(int i=0;i<b;i++)
| ^
main.cpp:11:58: error: invalid types ‘const int[int]’ for array subscript
11 | dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + (str1[i]!=str2[j]));
| ^
main.cpp:11:67: error: invalid types ‘const int[int]’ for array subscript
11 | dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + (str1[i]!=str2[j]));
| ^
main.cpp:13:19: error: ‘l2’ was not declared in this scope; did you mean ‘l1’?
13 | return dp[l1][l2];
| ^~
|
ソースコード
#include <algorithm>
using namespace std;
#define rep(i,b) for(int i=0;i<b;i++)
int LevenshteinDistance(const string& str1, const string& str2){
static int dp[2048][2048]; // 16 MB
int l1 = str1.size(), l2 = str2.size();
rep(i,l1+1) dp[i][0] = i;
rep(i,l2+1) dp[0][i] = i;
rep(i,l1)rep(j,l2){
dp[i+1][j+1] = min(dp[i][j+1], dp[i+1][j]) + 1;
dp[i+1][j+1] = min(dp[i+1][j+1], dp[i][j] + (str1[i]!=str2[j]));
}
return dp[l1][l2];
}
#include <iostream>
int main(){
int n,m;
string s,t;
cin >> n >> m >> s >> t;
cout << LevenshteinDistance(s,t) << endl;
}
tubo28