博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Codeforces Round #396 (Div. 2) A.Mahmoud and Longest Uncommon Subsequence
阅读量:4361 次
发布时间:2019-06-07

本文共 1796 字,大约阅读时间需要 5 分钟。

题目链接:http://codeforces.com/contest/766/problem/A

A. Mahmoud and Longest Uncommon Subsequence

While Mahmoud and Ehab were practicing for IOI, they found a problem which name was Longest common subsequence. They solved it, and then Ehab challenged Mahmoud with another problem.

Given two strings a and b, find the length of their longest uncommon subsequence, which is the longest string that is a subsequence of one of them and not a subsequence of the other.

A subsequence of some string is a sequence of characters that appears in the same order in the string, The appearances don't have to be consecutive, for example, strings "ac", "bc", "abc" and "a" are subsequences of string "abc" while strings "abbc" and "acb" are not. The empty string is a subsequence of any string. Any string is a subsequence of itself.

Input

The first line contains string a, and the second line — string b. Both of these strings are non-empty and consist of lowercase letters of English alphabet. The length of each string is not bigger than 105 characters.

Output

If there's no uncommon subsequence, print "-1". Otherwise print the length of the longest uncommon subsequence of a and b.

Examples
Input
abcd defgh
Output
5
Input
a a
Output
-1
Note

In the first example: you can choose "defgh" from string b as it is the longest subsequence of string b that doesn't appear as a subsequence of string a.

 

#include 
#include
#include
#include
#include
#include
#include
using namespace std;int main(){ ios::sync_with_stdio(false); cin.tie(0); string a,b; cin>>a>>b; if(a!=b){ cout<
<

 

 

转载于:https://www.cnblogs.com/hymscott/p/6380573.html

你可能感兴趣的文章
HDFS的设计
查看>>
如何实现一个php框架系列文章【开篇】
查看>>
APIClude常用代码
查看>>
Nginx wordpress rewrite
查看>>
java工具类--数据库操作封装类
查看>>
对PInvoke函数函数调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。...
查看>>
面向对象之多态的三种方式
查看>>
1:(0or1)
查看>>
最大子数组和(环状数组)
查看>>
Python脚本报错AttributeError: ‘module’ object has no attribute’xxx’解决方法
查看>>
sqlserver数据库索引
查看>>
pytorch 官方文档翻译
查看>>
秒杀多线程第三篇 原子操作 Interlocked系列函数
查看>>
boost之ThreadPool
查看>>
如何打造测试工程师精英团队?
查看>>
Linux(CentOS)下同时启动两个tomcat
查看>>
从B树、B+树、B*树谈到R 树
查看>>
java 转换流 打印流 数据流
查看>>
你知道如何判定一个大整数为素数吗?——米勒拉宾素数判定算法
查看>>
form 元素横向排列
查看>>