Source Code
#include <bits/stdc++.h>
#define ll long long
#define R return
#define pb push_back
#define F first
#define S second
#define B break
#define C continue
#define SI size()
using namespace std;
string s,t,r,rr,x,y;
int main()
{
    cin>>s>>t;
    ll n=s.SI,m=t.SI;
    ll h=0;
    for(ll i=0;i<n;i++){
        if(m-i-1<=0)B;
        r=s.substr(0,i+1);
        rr=t.substr(m-i-1,i+1);
        x=rr+s.substr(i+1,n-i-1);
        y=t.substr(0,m-i-1)+r;
        cout<<r<<" "<<rr<<endl;
        cout<<x<<" "<<y<<endl;
        if(x==y){
            h=1;B;
        }
    }
    if(h==1)cout<<x;
    else cout<<"-1";
    return 0;
}
Copy
Right into Two SOMAR.MH
GNU G++17
0 ms
360 KB
Wrong Answer