Language: C++

/*
AuThOr GaRyMr
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
string s[3];
int z[100000+20]; 
bool the_same(char c,char c1){
	if(c==c1) return 1;
	if(c=='?') return 1;
	if(c=='?') return 1;
	return 0;
}
void z_function(string S){
	int len=S.length();
	S='$'+S;
	int l,r;
	memset(z,0,sizeof(z));
	rb(i,2,len)
		if(!the_same(S[i],S[i-1])) break;
		else z[2]++;
	l=2,r=z[2]+1;
	rb(i,3,len){
		if(i<=r){
			z[i]=z[i-(l)+1];
			z[i]=min(z[i],r-i+1);
			if(z[i]+i-1==r){
				int ite=z[i]+1;
				rb(j,r+1,len){
					if(!the_same(S[j],S[ite++])) break;
					z[i]++;
				}
				l=i,r=i+z[i]-1;
			}
		}
		else{
			int ite=1;
			rb(j,i,len){
				if(!the_same(S[j],S[ite++])) break;
				z[i]++;
			}
			l=i,r=i+z[i]-1;
		}
	}
}
int res=INF;
string s_tmp;

void calc2(int i,int  j,int k){
	rb(_,0,s[k].length()){
		s_tmp="";
		bool Ok=1;
		rl(__,s[k].length(),_+1){
			s_tmp+=s[k][__-1];
		}
		int point1,point2;
		point1=_-1;
		point2=s[j].length()-1;
		while(point1>=0||point2>=0){
			if(point1<0){
				s_tmp+=s[j][point2];
			}
			else
			if(point2<0){
				s_tmp+=s[k][point1];
			}
			else
			if(s[j][point2]==s[k][point1]){
				s_tmp+=s[j][point2];
			}
			else{
				if(s[j][point2]=='?'){
					s_tmp+=s[k][point1];
				}
				else{
					if(s[k][point1]=='?'){
						s_tmp+=s[j][point2];
					}
					else Ok=0;
				}
			}
			point1--;
			point2--;
		}
		
		if(Ok){
//			reverse(ALL(s_tmp));
			string tmp=s[i];
			reverse(ALL(tmp));
			z_function(string(tmp+'&'+s_tmp));
			res=min((unsigned int)res,tmp.length()+s_tmp.length());
			rb(i,tmp.length()+2,tmp.length()+s_tmp.length()+1){
				if(z[i]+i-1==tmp.length()+s_tmp.length()+1){
					res=min((unsigned int)res,tmp.length()-z[i]+s_tmp.length());
				}
				if(z[i]==tmp.length()){
					res=min((unsigned int)res,s_tmp.length());
					break;
				}
			}
		}
	}
}
int main(){
	fastio;
	cin>>s[0]>>s[1]>>s[2];
	rep(i,3){
		rep(j,3){
			rep(k,3){
				if(i!=j&&j!=k&&i!=k){
					calc2(i,j,k);
				}
			}
		}
	}
	cout<<res<<endl;
	return 0;
}


Compiler output:
a.cc: In function 'void calc2(int, int, int)':
a.cc:111:32: error: no matching function for call to 'min(unsigned int, std::__cxx11::basic_string<char>::size_type)'
  111 |                         res=min((unsigned int)res,tmp.length()+s_tmp.length());
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/14/algorithm:60,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:51,
                 from a.cc:4:
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:111:32: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
  111 |                         res=min((unsigned int)res,tmp.length()+s_tmp.length());
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
In file included from /usr/include/c++/14/algorithm:61:
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:111:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
  111 |                         res=min((unsigned int)res,tmp.length()+s_tmp.length());
      |                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:114:48: error: no matching function for call to 'min(unsigned int, std::__cxx11::basic_string<char>::size_type)'
  114 |                                         res=min((unsigned int)res,tmp.length()-z[i]+s_tmp.length());
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:114:48: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
  114 |                                         res=min((unsigned int)res,tmp.length()-z[i]+s_tmp.length());
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:114:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
  114 |                                         res=min((unsigned int)res,tmp.length()-z[i]+s_tmp.length());
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a.cc:117:48: error: no matching function for call to 'min(unsigned int, std::__cxx11::basic_string<char>::size_type)'
  117 |                                         res=min((unsigned int)res,s_tmp.length());
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  233 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:233:5: note:   template argument deduction/substitution failed:
a.cc:117:48: note:   deduced conflicting types for parameter 'const _Tp' ('unsigned int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'})
  117 |                                         res=min((unsigned int)res,s_tmp.length());
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  281 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algobase.h:281:5: note:   candidate expects 3 arguments, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5686:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(initializer_list<_Tp>)'
 5686 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5686:5: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/14/bits/stl_algo.h:5696:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(initializer_list<_Tp>, _Compare)'
 5696 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/14/bits/stl_algo.h:5696:5: note:   template argument deduction/substitution failed:
a.cc:117:48: note:   mismatched types 'std::initializer_list<_Tp>' and 'unsigned int'
  117 |                                         res=min((unsigned int)res,s_tmp.length());
      |                                             ~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~