Data Transmission
Time limit2sMemory limit1024 MB
Given two binary strings s and t, the task is to decide whether t equals s or differs from it by one swap of adjacent bits.
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
Data is sent from a transmitter to a receiver over a communication channel as a sequence of bits. The channel may distort the sequence during transmission, so the sequence received by the receiver can differ from the sequence sent by the transmitter. One type of distortion is the swap of two adjacent bits. In this case, and differ at exactly two adjacent positions and , where and , and for every other than and .
You are a researcher working on information transmission. You are designing a coding scheme for an important government channel. The code must be able to correct one adjacent bit swap. To assess the channel's reliability, the test works as follows. Several bit sequences are sent, the received sequences are stored, and then they are compared with what was sent. The reliability is judged by the fraction of sequences that arrived without distortion or with a single adjacent swap.
Comparing the sequences by hand is too laborious because they are long. Write a program that, given two sequences and , determines whether can be obtained from by performing at most one swap of adjacent symbols.
Input
The first line contains the sequence , and the second line contains the sequence . Both sequences are non-empty, consist only of 0 and 1, and have length at most 100000.
Output
Print YES if can be obtained from in the way described above. Otherwise, print NO.