[LCS]Uva531 Compromise

瑞数6.5逆向实战:手把手教你用RPC搞定cookie sign加密(附环境补全技巧) 本文深入解析瑞数6.5逆向实战,重点探讨如何结合环境补全与RPC调用技术来应对其动态加密机制。文章详细介绍了环境指纹采集、双重验证等核心防护原理,并提供了基于Puppeteer的RPC实现方案,手把手教你搞定cookie sign加密,附有实用的环境补全技巧与完整代码示例。 阅读详情

LCS详解
。。。。。。。。。。。。。。。。。。。。。。。。。。
>

Compromise

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 Germany will fulfill the criteria, our government has so many wonderful options (raise taxes, sell stocks, revalue the gold reserves,…) that it is really hard to choose what to do.
Therefore the German government requires a program for the following task:
Two politicians each enter their proposal of what to do. The computer then outputs the longest common subsequence of words that occurs in both proposals. As you can see, this is a totally fair compromise (after all, a common sequence of words is something what both people have in mind).
Your country needs this program, so your job is to write it for us.
Input Specification
The input file will contain several test cases.
Each test case consists of two texts. Each text is given as a sequence of lower-case words, separated by whitespace, but with no punctuation. Words will be less than 30 characters long. Both texts will contain less than 100 words and will be terminated by a line containing a single ‘#’.
Input is terminated by end of file.
Output Specification
For each test case, print the longest common subsequence of words occuring in the two texts. If there is more than one such sequence, any one is acceptable. Separate the words by one blank. After the last word, output a newline character.
Sample Input
die einkommen der landwirte
sind fuer die abgeordneten ein buch mit sieben siegeln
um dem abzuhelfen
muessen dringend alle subventionsgesetze verbessert werden
#
die steuern auf vermoegen und einkommen
sollten nach meinung der abgeordneten
nachdruecklich erhoben werden
dazu muessen die kontrollbefugnisse der finanzbehoerden
dringend verbessert werden
#
Sample Output
die einkommen der abgeordneten muessen dringend verbessert werden
题意:给定两个文本,要求输出最多相同的单词序列。

思路:LCS,把单词一个一个记录,,strcmp(s1,s2)相同为0,不同为1。。
这道题主要是打印路径,,递归打印,具体看代码

#include<iostream>
#include<cstdio>
#include<ctime>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<set>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
#ifdef WIN32
#define AUTO "%I64d"
#else
#define AUTO "%lld"
#endif
#define INF 0x3f3f3f3f
#define clock CLOCKS_PER_SEC
#define cle(x) memset(x,0,sizeof(x))
#define maxcle(x) memset(x,127,sizeof(x))
#define mincle(x) memset(x,-1,sizeof(x))
#define cop(a,x) memcpy(x,a,sizeof(a))
#define FROP "Uva"
#define C(a,b) next_permutation(a,b)
#define LL long long
#define smin(x,tmp) x=min(x,tmp)
using namespace std;
const int N=110,M=35;
char s1[N][M],s2[N][M];
int f[N][N],n,m,path[N][N];
int ans;
void LCS()
{
    for(int i = 1; i <= n; i++)
        for(int j = 1; j<= m; j++)
        {
            if(!strcmp(s1[i],s2[j]))
                f[i][j]=f[i-1][j-1]+1,path[i][j]=1;
            else if(f[i-1][j]>f[i][j-1])f[i][j]=f[i-1][j],path[i][j]=2;
            else f[i][j]=f[i][j-1],path[i][j]=3;
        }
    ans=f[n][m];
}
void print(int i,int j)
{
    if(!i||!j)return;
    if(path[i][j]==1)
    {
        print(i-1,j-1);
        if(--ans==0)printf("%s\n",s1[i]);
        else printf("%s ",s1[i]);
    }
    else if(path[i][j]==2)print(i-1,j);
    else print(i,j-1);
}
int main()
{
    freopen(FROP".in","r",stdin);
    freopen(FROP".out","w",stdout);
    while(scanf("%s",s1[++n])!=EOF){
        while(scanf("%s",s1[n+1])&&s1[n+1][0]!='#')n++;
        while(scanf("%s",s2[m+1])&&s2[m+1][0]!='#')m++;
        LCS();
        print(n,m);
        n=0,m=0;
    }
    return 0;
}
【液晶专题】从外挂到In-Cell/ On-Cell/ OGS再也不会傻傻分不清楚了 触控技术经历了从外挂式到内嵌式的革新,主要方案包括外挂式(Out-Cell)、OGS、On-Cell和In-Cell。 阅读详情

相关推荐

网络设备心跳线带宽高导致虚拟化平台不稳定的问题处理

本文记录了网络设备心跳线带宽高导致虚拟化平台不稳定的问题处理一例。

forestqq的博客 2228

浅谈OCR之Onenote 2010

上一次我们讨论了Tesseract OCR引擎的用法,作为一款老牌的OCR引擎,目前已经开源,最新版本3.0中更是加入了中文OCR功能,再加上Google的更新、维护,可以说是潜力很大,值得期待。由上一次的测试结果也可以看出,Tesseract的OCR结果还不是很理想,尤其是中英文混合的文字,其识别率有限。本次我们来关注下Office 2010中的Onenote,调用其API来测试OCR功能。 ...

weixin_30339969的博客 5万+

Vue项目实战:用DataV的dv-scroll-board打造高颜值滚动表格(附完整代码)

本文详细介绍了如何在Vue项目中使用DataV的dv-scroll-board组件打造高颜值滚动表格。从基础集成到高级配置,包括动态数据处理、深度样式定制、性能优化策略以及交互增强方案,帮助开发者快速实现企业级数据展示需求。特别针对样式优化和滚动表格的常见问题提供了实用解决方案。

weixin_30892037的博客 499

LCS与打印路径

/* LCS */ #include<bits/stdc++.h> using namespace std; const int maxn = 1000; int dp[maxn][maxn], c[maxn][maxn]; int str1[maxn],str2[maxn]; int k; void dfs(int i,int j){ ...

weixin_30586085的博客 150

中山大学_数据科学与计算机_预推免

前言 2019 年 9 月中旬是中山大学预推免时间,本人没能进到夏令营,但是最后在预推免上岸也算不幸中的万幸。 记忆不一定准确,但希望能帮到他人。 想看 流程 的可以直接看总结,正文部分有本人心路历程。 预推免 中山大学的预推免大致可以分为 报道,机试,面试 三大部分,而且尤其是面试,所有人加起来总时长 3 天,幸运的是,本人被安排在第一天的下午第一场,上午就是机试,报道,机试,面试,无缝衔接。 ...

一把健 5208

Sciter教程_00_创建HelloWorld工程

本教程记录Sciter工程的创建和编译运行的过程。

qq_36707072的博客 2277

LCS打印路径

第三遍做这道题,对DP有了更深的理解。动态规划是一种解决问题的方法、途径,最优化原理(principle of optimality),把多阶段过程转化为一系列单阶段问题,利用各阶段之间的关系,逐个求解。 说明:动态规划要求其子问题既要独立又要重叠,这初看上去貌似存在矛盾,其实不然。只是这里说的是两个不同的 概念。独立指的是同一问题的两个子问题不共享资源。而重叠子问题指的是子问题可以作为不同的...

weixin_30512785的博客 199

Android 17为什么会重写MessageQueue

DeliQueue 通过消除 MessageQueue 中的锁,提升了系统和应用的性能。合成基准测试: 得益于并发能力的提升(Treiber 栈)和更快的插入速度(最小堆),向繁忙队列进行多线程插入的速度比传统 MessageQueue 快了高达 5000 倍。Perfetto 追踪分析: 在从内部测试人员处获取的 Perfetto 追踪记录中,我们看到应用主线程在锁竞争上消耗的时间减少了 15%。

xiangzhihong8的专栏 270

HDU 1159 Common Subsequence (LCS)

Common Subsequence Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 38474    Accepted Submission(s): 17654 Problem Description A sub

Mr_Treeeee的博客 561

Trae 保姆级使用指南,零基础小白也能实现编程。

Trae 使用指南 Trae AI 使用 零基础编程 满血版 DeepSeek-R1&V3 AI IDE 深度理解中文开发场景 傻瓜式编程 编程入门 开发入门

Mr.L-OAM的博客 5818

verilog实现步进电机脉冲分配器(三相六拍)基于Nexys4DDR开发板

使用Verilog HDL设计的一个能够自启动、具有正反转功能的三相六拍步进电机脉冲分配器。已经写好Nexy4DDR的管脚约束文件 可以通过Nexys4DDR开发板的PMOD接口连接步进电机进行调试。 使用verilog语言 在vivado2018.2下运行编译下载都正确,(也可在ISE,QuartusII下使用)下面是工程截图: ...

QQ_778132974的博客 2593

uva 531 Compromise(LCS)

题目连接:531 - Compromise 题目大意:给出两组字符串, 各含若干的字符串, 要求求两组字符串的最长公共子序列, 并输出最长的方案, 若有多种可能输出任意一种。 解题思路:普通的最长子序列问题, 和一般求解一样, 不过要记录路径, 我的做法是开两各数组记录移动方式, x[p][q], y[p][q]。当x[p][q] == p - 1 && y[p][q] ==

不慌不忙、不急不躁 1450

Android 13.0 app进程保活白名单功能实现

在13.0的系统rom产品开发中,在某些重要的app即使进入后台,产品需求要求也不想被系统杀掉进程,需要app长时间保活,就是app进程保活白名单功能的实现, 所以需要在系统杀进程的时候不杀掉白名单的进程,接下来就看怎么样来实现这些功能

安卓兼职framework和app工程师的博客 3143

UVA - 531 - Compromise (LCS)

题目链接:https://vjudge.net/problem/UVA-531 题意:以单词为单位的LCS(Longest common subsequence) 错误代码: #include #include #include #include #include #include #include #include #include #include #includ

mr_zj_的博客 296

android 蓝牙通讯demo

android 下蓝牙通讯demo,实现了发现蓝牙,使能蓝牙,通过蓝牙发送消息。

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

UVA 531 - Compromise(dp + LCS打印路径)

Compromise 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 ...

weixin_30730053的博客 148

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

UVA 531 Compromise(LCS算法+打印路径)

Compromise                                                Time Limit: 3000ms                    Memory Limit: 131072KB [PDF Link] In a few months the European Currency Union will become a r

Menglei Min 1009

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

uva531- Compromise(lcs+打印路径)

题意: 给你两段文字,求最大相同单词数。 思路: lcs的代码,+打印 代码如下:#include <iostream> #include <cstdio> #include <cstring> #include <algorithm> using namespace std; const int N = 105; int dp[N][N]; char a[N][N], b[N][N]; i

不要皱眉 406

uva 531 - Compromise(LCS+打印路径)

1、http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=114&page=show_problem&problem=472 2、题目大意:‘ 给定两篇文章,由英文单词组成,求最长公共子序列,难点在于打印路径,需要排除打印 3、题目:   Compromise 

sdjzping的专栏 1112

UVA 531 Compromise(LCS路径还原)

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 ...

本该如此 260

uva531 - Compromise(动规,lcs)

最长公共子序列+输出路径。 对路路径的输出我们要注意题意, 如果结果不含有单词的话,连空行也不会输出的。 对于: # # 就什么也不输出。 其他的原路返回输出即可。 #include #include #include using namespace std; #define M 35 #define N 105 int la, lb, dp[N][N], pa[N][N],

稻草人 901

uva 531·Compromise(LCS---路径打印)

题目: 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 ex...

weixin_30292745的博客 107

UVa 531 Compromise

这道题目要求找出两段文本的最长公共单词子序列(LCS),并输出该序列。输入由多个测试用例组成,每个测试用例包含两段以#结尾的文本。输出任意一个最长公共子序列。解题思路采用动态规划,定义dp[i][j]表示第一个文本前i个单词和第二个文本前j个单词的LCS长度。转移时,若单词相同则dp[i][j] = dp[i-1][j-1] + 1,否则取max(dp[i-1][j], dp[i][j-1])。通过回溯路径记录LCS的具体单词。时间复杂度为O(n*m),适用于单词数不超过100的情况。代码实现中读取输入

寂静山林 158

POJ 2250 Compromise (UVA 531)

LCS问题。基金会DP。 我很伤心WA非常多。就在LCS问题,需要记录什么路。 反正自己的纪录path错误,最后,就容易上当。 没有优化,二维阵列,递归打印,cin.eof() 来识别 end of file 标识。 至于单词用map 映射的。事实上也用不着,直接二维string或者 二维char 然后strcmp 也行。 Special Jud...

aofan9566的博客 128

UVa 531: Compromise

求最长公共子序列(LCS)并打印序列。dp解决,各节点标记最终的序列选择,最后递归打印即可。 我的解题代码如下: #include #include #include #include #include using namespace std; #define max(a,b) (a>b?a:b) #define WORDLEN 32 #define SENTENCELEN 102

rising_fallmoon的专栏 928

uva 531 - Compromise

最长公共子序列的变形 就是要求输出路径 用个vis记录一下 回溯输出就可以了 #include <algorithm> #include <cstring> #include <cstdio> using std::max; int n,m,q; char str[50]; char s[110][35]; char s2[...

dianmairou5198的博客 151
上一篇: [LCS][LIS]Uva10635]
下一篇: [区间dp]Hdu2467 String painter
Freddddddddddd
博客等级 码龄10年 2粉丝 42原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值