質問編集履歴
1
コードの最適化
test
CHANGED
File without changes
|
test
CHANGED
@@ -34,7 +34,7 @@
|
|
34
34
|
|
35
35
|
int i,j,x,y,k,l;
|
36
36
|
|
37
|
-
int length1
|
37
|
+
int length[100];
|
38
38
|
|
39
39
|
int dp[1001][1001];
|
40
40
|
|
@@ -50,7 +50,13 @@
|
|
50
50
|
|
51
51
|
|
52
52
|
|
53
|
+
for(i=0;i<n;i++) {
|
54
|
+
|
53
|
-
|
55
|
+
scanf("%s",str[i]);
|
56
|
+
|
57
|
+
length[i]=strlen(str[i]);
|
58
|
+
|
59
|
+
}
|
54
60
|
|
55
61
|
|
56
62
|
|
@@ -64,31 +70,19 @@
|
|
64
70
|
|
65
71
|
|
66
72
|
|
67
|
-
length1=strlen(str[i]);
|
68
|
-
|
69
|
-
//for(y=0;y<=length1;y++) dp[0][y]=y;
|
70
|
-
|
71
|
-
|
72
|
-
|
73
73
|
for(j=i+1;j<n;j++){
|
74
74
|
|
75
75
|
|
76
76
|
|
77
77
|
flag2=0;
|
78
78
|
|
79
|
-
|
80
|
-
|
81
|
-
length2=strlen(str[j]);
|
82
|
-
|
83
|
-
//for(x=0;x<=length2;x++) dp[x][0]=x;
|
84
|
-
|
85
79
|
|
86
80
|
|
87
|
-
if(abs(length
|
81
|
+
if(abs(length[i]-length[j])<10){
|
88
82
|
|
89
83
|
flag2++; //文字の長さの差が10以上ならOK
|
90
84
|
|
91
|
-
for(x=1;x<=length
|
85
|
+
for(x=1;x<=length[j];x++){
|
92
86
|
|
93
87
|
|
94
88
|
|
@@ -96,7 +90,7 @@
|
|
96
90
|
|
97
91
|
|
98
92
|
|
99
|
-
for(y=1;y<=length
|
93
|
+
for(y=1;y<=length[i];y++){
|
100
94
|
|
101
95
|
if(str[i][y-1]!=str[j][x-1]) cost=1;
|
102
96
|
|
@@ -110,7 +104,7 @@
|
|
110
104
|
|
111
105
|
|
112
106
|
|
113
|
-
if(flag1>=length
|
107
|
+
if(flag1>=length[i]) break;
|
114
108
|
|
115
109
|
|
116
110
|
|
@@ -142,7 +136,7 @@
|
|
142
136
|
|
143
137
|
|
144
138
|
|
145
|
-
if(
|
139
|
+
if(flag1<length[i] && flag2!=0) {
|
146
140
|
|
147
141
|
count++;
|
148
142
|
|