-
Notifications
You must be signed in to change notification settings - Fork 4
/
BCSTR.cpp
55 lines (52 loc) · 964 Bytes
/
BCSTR.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
#include<bits/stdc++.h>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define alphaa "abcdefghijklmnopqrstuvwxyz"
#define ALPHAA "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define faster() ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int,int> II;
const ld pi=2*acos(0);
const ll inf = LLONG_MAX;
const ll ninf = LLONG_MIN;
const int oo = INT_MAX;
const int noo = INT_MIN;
string a;
string b;
int DP[1001][1001] = {0};
void init(){
cin >> a >> b;
}
void process(){
for(int i=0;i<a.length();i++){
for(int j=0;j<b.length();j++){
if(a[i] == b[j]){
DP[i+1][j+1] = DP[i][j] + 1;
}
else DP[i+1][j+1] = max(DP[i+1][j] ,DP[i][j+1]);
}
}
cout << DP[a.length()][b.length()];
}
int main(){
faster();
init();
process();
return 0;
}