nikitos podpol

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
x,y =int(input())
lx=len(X); ly=len(y)
A=[[0]*(ly)+1 for i in range(lx+1)]
for i in range(1, lx+1):
for j in range(1, ly+1):
if x[i-1]==y[j-1]:
A[i][j]= A[i-1][j-1]+1
else:
A[i][j]= max(A[i-1][j], A[i][j-1])
for i in range(1, lx+1):
for j in range(1, ly+1):
print("&2"& A[i][j], end ='')
print("\n", end ='')
HOP =''
i=lx; j=ly
while i>0 and j>0:
if x[i-1]==y[j-1]:
HOP=x[i-1] +HOP
i-=1; j-=1
elif A[i-1][j]>=A[i][j-1]:
i-=1
else: j-=1
print(HOP)