-
Notifications
You must be signed in to change notification settings - Fork 14
/
10340.cpp
33 lines (30 loc) · 969 Bytes
/
10340.cpp
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
#include<iostream>
#include<vector>
using namespace std;
int main(){
string row, col;
while(cin>>row>>col){
int m, n;
m=row.length();
n=col.length();
int i, j;
int tower[m+1][n+1];
for(i=0; i<m+1; i++)
tower[i][0]=0;
for(j=0; j<n+1; j++)
tower[0][j]=0;
for(i=1; i<m+1; i++){
for(j=1; j<n+1; j++){
if(row[i-1] == col[j-1])
tower[i][j] = tower[i-1][j-1] + 1;
else
tower[i][j] = max(tower[i-1][j], tower[i][j-1]);
}
}
if(tower[m][n]==m)
cout<<"Yes";
else
cout<<"No";
cout<<endl;
}
}