시간 제한 메모리 제한 제출 정답 맞은 사람 정답 비율
1 초 128 MB 48 13 9 40.909%

문제

문자열 A의 부분 문자열이란, A에 속하는 하나 또는 그 이상의 문자(연속하지 않아도 된다)를 이용해서 만든 새로운 문자열이다. 이때, A에서의 순서를 그대로 유지해야 된다.

두 문자열 A와 B가 주어진다. 이때, A의 부분 문자열이면서, B의 부분 문자열이 아닌 가장 짧은 부분 문자열을 구하는 프로그램을 작성하시오.

입력

첫째 줄에 문자열 A, 둘째 줄에 문자열 B가 주어진다. 문자열은 알파벳 소문자로만 이루어져 있고, 길이는 2000보다 작거나 같다. 항상 정답이 존재하는 경우만 입력으로 주어진다. 

출력

첫째 줄에 A의 부분 문자열이면서, B의 부분 문자열이 아닌 가장 짧은 부분 문자열의 길이를 출력하고, 둘째 줄에는 문자열을 출력한다. 만약, 가능한 문자열이 여러 가지인 경우에는 아무거나 출력한다.

예제 입력 1

ababaa
abbaa

예제 출력 1

3
bab
W3sicHJvYmxlbV9pZCI6IjMyNDQiLCJwcm9ibGVtX2xhbmciOiIwIiwidGl0bGUiOiJcdWI0NTAgXHViZDgwXHViZDg0IFx1YmIzOFx1Yzc5MFx1YzVmNCAyIiwiZGVzY3JpcHRpb24iOiI8cD5cdWJiMzhcdWM3OTBcdWM1ZjQgQVx1Yzc1OCBcdWJkODBcdWJkODQgXHViYjM4XHVjNzkwXHVjNWY0XHVjNzc0XHViNzgwLCBBXHVjNWQwIFx1YzE4ZFx1ZDU1OFx1YjI5NCBcdWQ1NThcdWIwOTggXHViNjEwXHViMjk0IFx1YWRmOCBcdWM3NzRcdWMwYzFcdWM3NTggXHViYjM4XHVjNzkwKFx1YzVmMFx1YzE4ZFx1ZDU1OFx1YzljMCBcdWM1NGFcdWM1NDRcdWIzYzQgXHViNDFjXHViMmU0KVx1Yjk3YyBcdWM3NzRcdWM2YTlcdWQ1NzRcdWMxMWMgXHViOWNjXHViNGUwIFx1YzBjOFx1Yjg1Y1x1YzZiNCBcdWJiMzhcdWM3O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