2018-BNUZ-ACM-GDCPC选拔赛(耻辱赛)D 【补题】

原创 2018年04月15日 22:10:41

A. Mahmoud and Longest Uncommon Subsequence
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard 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
Copy
abcd
defgh
output
Copy
5
input
Copy
a
a
output
Copy
-1


这道逗你玩系列(小q说的),确实是逗你玩,搞的什么子串什么鬼的,题意是两个字符串,能不能从一个字符串中取出一个子串与a的子串不相同,输出最长的可能,其实最长的子串就是本身,也就是说两个字符串如果不相等,那么长的那个的长度就是可以找到的最大长度,如果相等不可能找到合适的子串。

(某q还说5行过。。。。。我还是做不到,这种工作还是交给我们的铁头王来吧)


代码如下 : 

#include <bits/stdc++.h>

using namespace std;
string a,b;
int main (){
	cin >> a;
	cin >> b;
	int len1 = a.length();
	int len2 = b.length();
	int flag = 0;
//	cout << a << endl << b;
	if(a == b){
		flag = 1;
	}
	if(flag){
		puts("-1");
	}else {
		printf("%d\n",max(len1,len2));
	}
	return 0;
}


2018-BNUZ-ACM-GDCPC选拔赛(耻辱赛)E 【补题】

B. Mahmoud and a Triangletime limit per test 2 secondsmemory limit per test 256 megabytesinput stand...
  • bnuz_kuye
  • bnuz_kuye
  • 2018-04-15 21:52:39
  • 14

2018-BNUZ-ACM-GDCPC选拔赛 【补题】

第一次GDCPC选拔,说不想去是不可能的,中午回来就赶紧休息,下午又早早的来到教室,可是还是自己的问题吧,又是卡题,就是一点思路都没有,就想着暴力,结果过不去各种wa还有tle,第一次出校打比赛的机会...
  • YIOWOIY
  • YIOWOIY
  • 2018-04-16 00:58:10
  • 7

补题清单

Codeforces Round #364 (Div. 2) FBestCoder Round #84 EBC2周年 D2016 Multiset 1 C 2016 Multiset 1 G 2...
  • acm_fighting
  • acm_fighting
  • 2016-07-24 14:12:34
  • 240

2013高教社杯全国大学生数学建模竞赛题目D题(含附件)

  • 2013年09月13日 10:40
  • 29.75MB
  • 下载

华师ACM新生赛1003

给出n(n≤100000),计算n!。 由于n!比较大,现在要求输出n!对1000000007取模的值。   解题思路:题目将会给出很多组n来计算n!,需要考虑的问题有两个。第一个是n!会非常大...
  • Alien_X
  • Alien_X
  • 2014-12-04 15:08:10
  • 326

2018 ZJU 天梯赛选拔第二场 - E

2018 ZJU 天梯赛选拔第二场 - E 难度大如狗 Time Limit: 1 Second Memory Limit: 65536 KB 风学长有一个只包含 “+” 和数字...
  • j___t
  • j___t
  • 2018-03-01 00:56:57
  • 88

2016 青岛区域赛补题 B(模拟), G(费用流)

B: 就模拟下。 感觉自己不太熟悉这种代码。 #include using namespace std; #define N 35 int b[N],a[N]; //int r[6][8]{ ...
  • now_ing
  • now_ing
  • 2017-10-19 22:40:38
  • 48

SCNU_2013省赛选拔赛#2(Just for 12)解题报告

比赛地址:http://acm.hust.edu.cn/vjudge/contest/view.action?cid=20835#overview A题:     模拟题,扫描一次,若发现...
  • SCNU_Jiechao
  • SCNU_Jiechao
  • 2013-03-31 21:29:26
  • 1088

2016中国大学生程序设计竞赛-网络赛

再接再厉吧!
  • Kiritow
  • Kiritow
  • 2016-08-14 17:27:38
  • 3096

第七届ACM山东省赛-D Swiss-system tournament

Time Limit: 2000MS Memory limit: 131072K题目描述 A Swiss-system tournament is a tournament which uses a...
  • huayunhualuo
  • huayunhualuo
  • 2016-06-10 08:30:36
  • 1022
收藏助手
不良信息举报
您举报文章:2018-BNUZ-ACM-GDCPC选拔赛(耻辱赛)D 【补题】
举报原因:
原因补充:

(最多只允许输入30个字)