#P3741. 基于位运算的最长公共子序列
基于位运算的最长公共子序列
题目描述
小欣在公园玩时发现有个玩小游戏的地方,小游戏的规则是:有两排标有字符的球,字符属于{A<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">,</span>T,C<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">,</span>G},第1<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">排有</span>N1个球,第2<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">排有</span>N2个球(1<=N1,N2<=50000)<span style="font-family:宋体;mso-ascii-font-family:
Calibri;mso-hansi-font-family:Calibri">,在第</span>1排的球中选出1<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">些来和第</span>2排的配对,每配出1<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">对就得</span>1分,已经配对了的就不能再用了。小欣觉得这个游戏太简单了,不就是用个…<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">就可以了吗?但他发现规则的最后</span>1行说:配对的连线不能相交,相交的概念就是对于第1<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">排的</span>I,J<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">这</span>2个球,它们配对的分别是F[I]<span style="font-family:宋体;mso-ascii-font-family:Calibri;
mso-hansi-font-family:Calibri">,</span>F[J],它们相交当且仅当I<J and F[I]>F[J]<span style="font-family:宋体;
mso-ascii-font-family:Calibri;mso-hansi-font-family:Calibri">。这就难倒小欣了,现在请你帮助小欣编程求出最大得分。</span>
输入格式
第1行: 两个数: N1,N2
第2行:N1个字符
第3行:N2个字符
输出格式
2 2
CT
AG
0