Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<bits/stdc++.h>
- using namespace std;
- #define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
- #define pb push_back
- #define ll long long
- ll mod=1e9+7;
- void test_case()
- {
- string a,b;
- cin>>a>>b;
- if(a.size()!=b.size()) {
- cout<<"NO";
- return;
- }
- bool flag=1;
- int n=a.size();
- for(int i=0;i<n-1;i++) {
- if(a.substr(i,2)!=b.substr(i,2)) {
- // 11 --> 10 01
- // 10 --> 11
- // 01 --> 11
- // 00 --> 00
- if(a.substr(i,2)=="11")
- {
- if(b.substr(i,2)=="01" || b.substr(i,2)=="10")
- {
- a[i]=b[i];
- a[i+1]=b[i+1];
- }
- else
- {
- flag=0;
- break;
- }
- }
- else if(a.substr(i,2)=="10" || a.substr(i,2)=="01")
- {
- if(b.substr(i,2)=="11")
- {
- a[i]=b[i];
- a[i+1]=b[i+1];
- }
- else{
- flag=0;
- break;
- }
- }
- else {
- flag=0;
- break;
- }
- }
- }
- if(flag && a==b)
- cout<<"YES";
- else
- cout<<"NO";
- }
- int main()
- {
- fastio
- // int t;
- // cin>>t;
- // while(t--)
- test_case();
- }
Add Comment
Please, Sign In to add comment