POJ 2250】的更多相关文章

POJ 2250 Compromise(LCS)解题报告 题目链接:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=87125#problem/D 题目: Description In a few months the European Currency Union will become a reality. However, to join the club, the Maastricht criteria must be fulf…
题目链接:http://poj.org/problem?id=2250 思路分析:最长公共子序列问题的变形,只是把字符变成了字符串,按照最长公共子序列的思路即可以求解. 代码如下: #include <stdio.h> #include <string.h> #define IsEqual(a, b) strcmp((a), (b)) == 0 enum { Left, Up, UpAndLeft }; int XLen, YLen; + ; ], Y[MAX_N][]; int…
题目链接: http://poj.org/problem?id=2250 Compromise Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 9284   Accepted: 3972   Special Judge Description In a few months the European Currency Union will become a reality. However, to join the clu…
题目字符串的LCS,输出解我比较不会,dp的时候记录从哪里转移来的,之后要一步一步转移回去把解存起来然后输出. #include<cstdio> #include<cstring> #define N 102 #define M 32 int n,m,dp[N][N],ans[N][N]; char s1[N][M],s2[N][M],str[N][M]; void solve(){ memset(dp,0,sizeof dp); memset(ans,0,sizeof ans);…
题目传送门 题意:求单词的最长公共子序列,并要求打印路径 分析:LCS 将单词看成一个点,dp[i][j] = dp[i-1][j-1] + 1 (s1[i] == s2[j]), dp[i][j] = max (dp[i-1][j], dp[i][j-1]) 代码: #include <cstdio> #include <iostream> #include <cstring> #include <algorithm> #include <strin…
compromise Time Limit:1000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u   Description In a few months the European Currency Union will become a reality. However, to join the club, the Maastricht criteria must be fulfilled, and this is…
Description In a few months the European Currency Union will become a reality. However, to join the club, the Maastricht criteria must be fulfilled, and this is not a trivial task for the countries (maybe except for Luxembourg). To enforce that Germa…
LCS问题.基金会DP. 我很伤心WA非常多.就在LCS问题,需要记录什么路. 反正自己的纪录path错误,最后,就容易上当. 没有优化,二维阵列,递归打印,cin.eof() 来识别 end of file 标识. 至于单词用map 映射的. 事实上也用不着,直接二维string或者 二维char 然后strcmp 也行. Special Judge 交 UVA 531 奇怪的PE了. .. 然后改成 flag 标记 输出 空格.最终都AC了. #include<cstdio> #inclu…
题目链接:https://vjudge.net/problem/POJ-2250 题目大意:给出n组case,每组case由两部分组成,分别包含若干个单词,都以“#”当结束标志,要求输出最长子序列. #include <iostream> #include <string> using namespace std; ], b[], ans[]; ][], num[][]; void LCSLength() { memset(dp, , sizeof(dp)); memset(num…
#include <iostream> #include <stack> #define MAXN 150 #include <string> using namespace std; int dp[MAXN][MAXN]; int mark[MAXN][MAXN]; string s_1[MAXN]; string s_2[MAXN]; stack <string> coll; int main() { int i; int j; string tem;…