time limit per test2 seconds

memory limit per test256 megabytes

inputstandard input

outputstandard output

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.

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

【题意】



给你两个串A和B,问你两个串的最长不公共子序列;

【题解】



如果两个串相同;

那么答案就为0;

答案不同的话;

看长度;

直接让长度长的那个串的长度当做答案;

(相同的话任意一个就好)



【完整代码】

#include <bits/stdc++.h>
using namespace std;
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define LL long long
#define rep1(i,a,b) for (int i = a;i <= b;i++)
#define rep2(i,a,b) for (int i = a;i >= b;i--)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define rei(x) scanf("%d",&x)
#define rel(x) scanf("%I64d",&x) typedef pair<int,int> pii;
typedef pair<LL,LL> pll; const int dx[9] = {0,1,-1,0,0,-1,-1,1,1};
const int dy[9] = {0,0,0,-1,1,-1,1,-1,1};
const double pi = acos(-1.0);
const int MAXN = 110; string a,b; int main()
{
//freopen("F:\\rush.txt","r",stdin);
cin >> a >> b;
if (a==b)
puts("-1");
else
{
int len1 = a.size(),len2 = b.size();
printf("%d\n",max(len1,len2));
}
return 0;
}

【codeforces 766A】Mahmoud and Longest Uncommon Subsequence的更多相关文章

  1. Codeforces Round #396 (Div. 2) A. Mahmoud and Longest Uncommon Subsequence 水题

    A. Mahmoud and Longest Uncommon Subsequence 题目连接: http://codeforces.com/contest/766/problem/A Descri ...

  2. Codeforces Round #396 (Div. 2) A - Mahmoud and Longest Uncommon Subsequence B - Mahmoud and a Triangle

    地址:http://codeforces.com/contest/766/problem/A A题: A. Mahmoud and Longest Uncommon Subsequence time ...

  3. 766A Mahmoud and Longest Uncommon Subsequence

    A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...

  4. Codeforces766A Mahmoud and Longest Uncommon Subsequence 2017-02-21 13:42 46人阅读 评论(0) 收藏

    A. Mahmoud and Longest Uncommon Subsequence time limit per test 2 seconds memory limit per test 256 ...

  5. 【codeforces 766C】Mahmoud and a Message

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  6. 【codeforces 766D】Mahmoud and a Dictionary

    time limit per test4 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  7. 【codeforces 766B】Mahmoud and a Triangle

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  8. 【codeforces 766E】Mahmoud and a xor trip

    [题目链接]:http://codeforces.com/contest/766/problem/E [题意] 定义树上任意两点之间的距离为这条简单路径上经过的点; 那些点上的权值的所有异或; 求任意 ...

  9. Codeforces Round #396(Div. 2) A. Mahmoud and Longest Uncommon Subsequence

    [题意概述] 找两个字符串的最长不公共子串. [题目分析] 两个字符串的最长不公共子串就应该是其中一个字符串本身,那么判断两个字符串是否相等,如果相等,那么肯定没有公共子串,输出"-1&qu ...

随机推荐

  1. 计算机网络.{wireshark的使用实验}

    ---恢复内容开始--- 三种选择 1 2 3 端口镜像:交换机的某个端口,接受或者发送的数据给另外一个端口 ARP欺骗: ARP欺骗是利用ARP协议自身的不足进行的欺骗 1 执行ping命令, 2 ...

  2. KiCad 工程用 Git 管理需要忽略哪些文件?

    KiCAD 工程用 Git 管理需要忽略哪些文件? KiCAD 使用的 文本格式,天生可以用 Git 来管理. 但是并非所有文件需要使用 Git 管理,以下文件可以忽略. *.bak fp-info- ...

  3. python 常规字符匹配

  4. 求x!在k进制下后缀零的个数(洛谷月赛T1)

    求x!在k进制下后缀和的个数 20分:     求十进制下的x!后缀和的个数 40分: 高精求阶乘,直接模拟过程 (我不管反正我不打,本蒟蒻最讨厌高精了) 60分     利用一个定理(网上有求x!在 ...

  5. UCloud-201809-001:Redis服务未授权访问漏洞安全预警

    UCloud-201809-001:Redis服务未授权访问漏洞安全预警 尊敬的UCloud用户,您好! 发布时间  2018-09-11更新时间  2018-09-11漏洞等级  HighCVE编号 ...

  6. LintCode刷题笔记--Flip Bits

    Flip Bits: 标签:位运算 题目:Determine the number of bits required to flip if you want to convert integer n  ...

  7. 阿里云发布敏感数据保护产品SDDP,数据贴身防护实现“外防内控”

    数据安全问题,尤其是个人信息保护问题,一直是所有企业和个人关注的重点问题,7月10日,阿里云针对云上企业正式发布一款敏感数据保护产品SDDP(Sensitive Data Detection and ...

  8. css 的float和inline-block区别

    CSS布局创建网站,浮动绝对占据了很大的比例.大块区域如主内容及侧边栏,以及在其中的小块区域,都可以看到浮动的影子.这里浮动是唯一的解决方案吗? 浮动通常表现正常,但有时候搞起来会很纠结.特别是处理内 ...

  9. Notepad++中Python脚本运行出现语法错误:IndentationError: unindent does not match any outer indentation level

    使用Notepad++编辑python代码运行遇到了这个问题: IndentationError: unindent does not match any outer indentation leve ...

  10. Java练习 SDUT-1133_模拟计算器

    C/C++经典程序训练3---模拟计算器 Time Limit: 1000 ms Memory Limit: 8192 KiB Problem Description 简单计算器模拟:输入两个整数和一 ...