Source Code
#include <bits/stdc++.h>

using namespace std ;

const int MAX = 2e5 + 10 ;

int arr[MAX] ;
int n ;

string s , t ;
string s2 , t2 ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>s ;
	cin>>t ;
	int n = s.size() ;
	for(int i = 0 ; i < n ; ++i)
	{
		s2 = s , t2 = t ;
		for(int j = 0 ; j < i ; ++j)
			swap(s2[j] , t2[n-i+j]) ;
		if(s2 == t2)
			return cout<<s2<<"\n" , 0 ;
	}
	return cout<<-1<<"\n" , 0 ;
}
Copy
Right into Two Bakry_
GNU G++17
0 ms
604 KB
Wrong Answer