GlobeX Cup '19 J5 - Aliens

View as PDF

Submit solution

Points: 15
Time limit: 0.6s
Python 1.8s
Memory limit: 256M

Problem type

Scientists are constantly listening for aliens. Because of the great distances, some things may come more delayed than others. Thus they need an algorithm that when given two strings, a and b (2 \le |a| = |b| \le 1\,000), determines whether it is possible to make b by taking a single substring of a and moving it to another index. It should also detect aliens when the two strings are the same.

Input Specification

The input will consist of two newline separated strings, a and b. Each string will only consist of lowercase letters.

Output Specification

Output aliens if it is possible, else no aliens.

Sample Input 1

abcdef
abcfde

Sample Output 1

aliens

Explanation for Sample 1

The substring f was moved to after index 3 (starting with 1).

Sample Input 2

abcdef
acbdfe

Sample Output 2

no aliens

Explanation for Sample 2

There is no single substring that can be moved to create the new string.


Comments

There are no comments at the moment.