-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path10029.cpp
More file actions
126 lines (116 loc) · 3.51 KB
/
10029.cpp
File metadata and controls
126 lines (116 loc) · 3.51 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/****** BISMILLAHIR RAHMANIR RAHIM ********\
/*********************************************************************\
# |--\ /--| | | | ----- /-------------\ #
# | \ / | | | | / | | #
# | \ / | | | | / | | #
# | | | | |/ | | #
# | | | | |\ | | #
# | | | | | \ | | #
# | | \ / | \ | | #
# --- --- \______ / | ----- ----- #
# #
# #
# #
# codeforces = Mukit09 #
# topcoder = mukitmkbs25 #
# codechef = mukit_mkbs #
# uva = mkbs_cse09 #
# spoj = mkbs_cse09 #
# CSE, CUET #
# facebook : https://www.facebook.com/hesitated.mkbs?ref=tn_tnmn #
# #
# #
\*********************************************************************/
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<string.h>
#include<string>
#include<stdlib.h>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<set>
using namespace std;
// Define Some Variables
#define eps 1e-14
#define si 25010
#define pi acos(-1.0)
#define inf (1<<30)-1
#define mod 1000000000 //10^9
//Define Some Functions
#define even(a) ((a)%2==0)
#define odd(a) ((a)%2==1)
#define max(a,b) (a>b ?a:b)
#define min(a,b) (a<b ?a:b)
#define pb push_back
#define mpair make_pair
#define sqr(a)((a)*(a))
#define area(x1,y1,x2,y2,x3,y3) (x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2)) //Area of a triangle
#define dist(x1,y1,x2,y2) (sqr(x1-x2)+sqr(y1-y2)) //Distance between two points
#define mem(a,v) memset(a,v,sizeof(a))
inline bool compare( double a, double b ) { return fabs( a-b ) < eps ; }
#define fr(i,a,b) for(i=a;i<=b;i++)
#define rep(i,a,b) for(i=a;i<b;i++)
#define rev(i,a,b) for(i=a;i>=b;i--)
typedef long long i64;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};
int n,cs=1,dp[si];
char ch[si][20];
int rec(int u)
{
if(u==n)
return 0;
int &ret=dp[u];
if(ret!=-1)
return ret;
int mx=0,v,p,l1,l2,i,j,sm;
rep(v,u+1,n)
{
l1=strlen(ch[u]);
l2=strlen(ch[v]);
sm=0;
j=0;
rep(i,0,l1)
{
if(j>=l2)
break;
if(ch[u][i]!=ch[v][j])
{
sm++;
if(l1>l2)
i++;
else
j++;
if(ch[u][i]!=ch[v][j])
sm++;
}
j++;
}
if(sm==1)
{
p=rec(v);
if(p>mx)
mx=p;
}
}
return ret=1+mx;
}
int main()
{
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
int i=0;
while(~scanf("%s",ch[i]))
i++;
mem(dp,-1);
n=i;
int ans=0;
rep(i,0,n)
ans=max(ans,rec(i));
printf("%d\n",ans);
return 0;
}