MSTRING - String problem


Cho hai xâu A và B. Tính độ dài của xâu con ngắn nhất của A mà không là xâu con của B. Xâu con không nhất thiết phải gồm các kí tự liên tiếp.

Input

Hai dòng là hai xâu A, B, độ dài <=1000, chỉ gồm các chữ cái 'a'..'z'.

Output

In ra độ dài nhỏ nhất tìm được

Sample

Sample input
 
banana 
anbnaanbaan 
 
Sample output
 
5 
 
(eg. banna) 

Sample input
 
babab 
babba 
 
Sample output
 
3 
 
(eg. aab) 

hide comments
anirudnits: 2018-05-20 15:34:23

There is only one set of input and the characters of s,t are lowercase alphabets.

Superty: 2016-05-19 01:45:25

Note that input data DOES consist only of lower case letters.
If there was an issue with this before, it seems to have been fixed now.

naruto09: 2016-01-24 09:44:26

substring == subsequence..!!

Scape: 2015-09-22 12:56:25

Wow, what a mess of a problem. Notes to future solvers:
1. Read the word "substring" as sub-sequence.
2. The input does not consist of only lower case letters. You will get wrong answer if you rely on this.
3. I got wrong answer with this: while (scanf("%s %s", S, T) != EOF). There are probably some extra characters in the input file. You will get wrong answer if you try to read till EOF.

Samar Holkar: 2015-06-04 14:56:24

Interesting Problem !!!

Zhouxing Shi: 2013-04-01 01:14:09

"Substring" doens't means "subsequence"!!!

Juɑƞ Chɑpɑrro: 2014-03-05 17:44:14

Input:
aaa
bbb
Output:
1
Input:
bab
aba
Output:
2
Input:
baba
abab
Output:
3

Last edit: 2013-03-31 06:00:12
Adel Ali: 2013-01-31 20:16:20

@Francky
It has nothing to do with languages! These terms became well known over the years! A substring has to be a succeeding sequence of characters within the string while a subsequence has not to be!

I'm actually having terrible time trying to interpret many of the problems statements on spoj! unlike other online judges, most of the problems have unclear statements, and many problems have their test cases inconsistent with the constraints which makes it a real pain to get an accepted solution! This is just a big waste of time!!

Last edit: 2013-01-31 20:17:22
Francky: 2013-01-31 08:29:33

@adel ali : is your language a sub-language of any ? If yes, I recommend you to try another intersection.

Adel Ali: 2013-01-31 07:35:18

what the fuck!?
If you don't know how to write clear problem statements, then never do it!!
Which bastard did tell you that a substring == a subsequence?!
Where is the admins?! How in the hell do you approve such problem statements?!

Last edit: 2013-01-31 07:36:23

Added by:~!(*(@*!@^&
Date:2009-02-28
Time limit:0.233s
Source limit:50000B
Memory limit:1536MB
Cluster: Cube (Intel G860)
Languages:All except: ERL JS-RHINO NODEJS PERL6 VB.NET
Resource:COI 04