#C10141. Similar Sequences
Similar Sequences
Similar Sequences
You are given two integer sequences. The task is to determine whether there exists at least one contiguous subarray (of any positive length) that appears in both sequences. Note that a single common element qualifies as a contiguous subarray of length 1. However, if one or both sequences are empty, then they do not contain any contiguous subarray.
Input Format: The input consists of two lines. The first line contains a sequence of space-separated integers representing the first sequence. The second line contains a sequence of space-separated integers representing the second sequence. If a line is empty, it represents an empty sequence.
Output Format: Output a single line with the word "similar" if the two sequences share at least one contiguous subarray (even of length 1), and "not similar" otherwise.
Example:
Input:
1 2 3 4 5
3 4 5 6 7
Output:
similar
Note: Two sequences are considered similar if they have at least one integer in common, since any single integer is a contiguous subarray.
inputFormat
The input is given via standard input (stdin) and consists of exactly two lines:
- The first line contains a sequence of space-separated integers. If the line is empty, the sequence is empty.
- The second line contains a sequence of space-separated integers. If the line is empty, the sequence is empty.
outputFormat
The output should be printed to standard output (stdout) and is a single word: either "similar" if the sequences share at least one contiguous subarray, or "not similar" if they do not.
## sample1 2 3 4 5
3 4 5 6 7
similar