๋ฌธ์
์ฝ๋
#include <iostream>
using namespace std;
int dp[3001][3001];
int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
string A,B; cin>>A>>B;
for(int i=3; i<=A.length(); i+=3){
for(int k=3; k<=B.length(); k+=3){
if(A.substr(i-3,3)==B.substr(k-3,3)) dp[i][k]=dp[i-3][k-3]+1;
else dp[i][k]=max(dp[i-3][k],dp[i][k-3]);
}
}
cout<<dp[A.length()][B.length()];
}
'Algorithm ๐ง๐ปโ๐ป > ๋ฐฑ์ค(BOJ)' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค,c++] 15649๋ฒ - N๊ณผ M(1) (0) | 2021.11.17 |
---|---|
[๋ฐฑ์ค,c++] 15643๋ฒ - Yee (0) | 2021.11.17 |
[๋ฐฑ์ค,c++] 15552๋ฒ - ๋น ๋ฅธA+B (0) | 2021.11.17 |
[๋ฐฑ์ค,c++] 1547๋ฒ - ๊ณต (0) | 2021.11.17 |
[๋ฐฑ์ค,c++] 1541๋ฒ - ์์ด๋ฒ๋ฆฐ ๊ดํธ (0) | 2021.11.17 |
[๋ฐฑ์ค,c++] 15240๋ฒ - Paint bucket (0) | 2021.11.17 |
๋๊ธ