回答編集履歴
4
update
answer
CHANGED
@@ -52,8 +52,8 @@
|
|
52
52
|
memset(n, '\0', sizeof(n));
|
53
53
|
memset(m, '\0', sizeof(m));
|
54
54
|
|
55
|
-
|
55
|
+
scanf("%s", n);
|
56
|
-
|
56
|
+
scanf("%s", m);
|
57
57
|
|
58
58
|
int i, j, cnt=0, flg;
|
59
59
|
int x=strlen(m);
|
3
update
answer
CHANGED
@@ -37,4 +37,45 @@
|
|
37
37
|
printf("count:%d\n",cnt);
|
38
38
|
return 0;
|
39
39
|
}
|
40
|
-
```
|
40
|
+
```
|
41
|
+
|
42
|
+
ご指摘を受けて修正版
|
43
|
+
```c
|
44
|
+
#include <stdio.h>
|
45
|
+
#include <string.h>
|
46
|
+
|
47
|
+
char n[100001];
|
48
|
+
char m[100001];
|
49
|
+
char z[100001];
|
50
|
+
|
51
|
+
int main(){
|
52
|
+
memset(n, '\0', sizeof(n));
|
53
|
+
memset(m, '\0', sizeof(m));
|
54
|
+
|
55
|
+
fgets(n, 100001, stdin);
|
56
|
+
fgets(m, 100001, stdin);
|
57
|
+
|
58
|
+
int i, j, cnt=0, flg;
|
59
|
+
int x=strlen(m);
|
60
|
+
int y=strlen(n);
|
61
|
+
printf("n:%d\n",x);
|
62
|
+
printf("m:%d\n",y);
|
63
|
+
|
64
|
+
for(i=0;i<x;i++){
|
65
|
+
flg=1;
|
66
|
+
for(j=0;j<y;j++){
|
67
|
+
if(m[i] == n[j]){
|
68
|
+
strcpy(z,n+(j+1));
|
69
|
+
strcpy(n+j,z);
|
70
|
+
y--;
|
71
|
+
flg=0;
|
72
|
+
break;
|
73
|
+
}
|
74
|
+
}
|
75
|
+
cnt+=flg;
|
76
|
+
}
|
77
|
+
printf("count:%d\n",cnt);
|
78
|
+
return 0;
|
79
|
+
}
|
80
|
+
```
|
81
|
+
私の貧富マシンでも100000件を1分程度で終了しました。
|
2
update
answer
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
if(m[i] == n[j]){
|
30
30
|
strcpy(n+j,n+(j+1));
|
31
31
|
flg=0;
|
32
|
-
|
32
|
+
break;
|
33
33
|
}
|
34
34
|
}
|
35
35
|
cnt+=flg;
|
1
update
answer
CHANGED
@@ -29,7 +29,7 @@
|
|
29
29
|
if(m[i] == n[j]){
|
30
30
|
strcpy(n+j,n+(j+1));
|
31
31
|
flg=0;
|
32
|
-
|
32
|
+
j=strlen(n);
|
33
33
|
}
|
34
34
|
}
|
35
35
|
cnt+=flg;
|