Language: C++

#include<iostream>
#include<vector>
#include<string>
#include<cstdlib>
#include<cstring>
#include<queue>
#include<cmath>
//#include<>
using namespace std;

#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define REPS(i, n) for(int i=1;i<=(int)(n);i++)
#define RREP(i, n) for(int i=(int)n-1;i>=0;i--)
#define RREPS(i, n) for(int i=(int)n;i>0;i--)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define X first
#define Y second

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef pair<int,string> pis;

int n, m;

int check(string s, string t){ // s \in t
	rep(i, (int)t.size() - (int)s.size() + 1){
		if(t.substr(i, s.size()) == s) return 1;
	}
	return 0;
}

string dp[1<<10][15];
vector<vector<string> > nxt;
vector<string> str;

pis dfs(int st,int last){
	if(!(st^(1<<last)))return pis(str[last].size(),str[last]);
	if(dp[st][last].size())return pis(dp[st][last].size(),dp[st][last]);
	pis re; re.first=1123;
	int n=nxt.size(),st2=st^(1<<last);
	rep(i,n)if(st2>>i&1){
		pis tmp=dfs(st2, i);
		tmp.X+=nxt[i][last].size();
		tmp.Y+=nxt[i][last];
		re=min(re,tmp);
	}
	dp[st][last]=re.Y;
	return re;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(false); cout.tie(false);
	while(cin >> n){
		if(!n)break;
		fill(dp[0],dp[0]+(15<<10),"");
		str.clear();
		vector<string> str_(n);
		rep(i,n)
			cin>>str_[i];
		int f=0;
		rep(i,n){
			f=0;
			rep(j,n)if(i!=j && check(str_[i],str_[j])){
				if(str_[i] != str_[j] || i < j) f=1;
			}
			if(!f)str.pb(str_[i]);
		}
		int m=str.size();
//rep(i,n)cout<<str_[i]<<",";cout<<endl;
		nxt.clear(); nxt=vector<vector<string> >(m,vector<string>(m));
		rep(i,m)rep(j,m)if(i!=j){
			nxt[i][j]=str[j];
			rep(k,str[i].size())
				if(str[i].substr(k)==str[j].substr(0,str[i].size()-k)){
					nxt[i][j]=str[j].substr(str[i].size()-k); break;
				}
	//if(!j)cout<<endl;
			//cout<<nxt[i][j]<<",";
		}

		pis re;re.X=1123;
		rep(i,m)
			re=min(re,dfs((1<<m)-1,i));
		cout<<re.Y<<endl;
		
	}
	return 0;
}

Compiler output:
a.cc: In function 'int main()':
a.cc:57:16: error: no matching function for call to 'std::basic_istream<char>::tie(bool)'
   57 |         cin.tie(false); cout.tie(false);
      |         ~~~~~~~^~~~~~~
In file included from /usr/include/c++/14/ios:46,
                 from /usr/include/c++/14/ostream:40,
                 from /usr/include/c++/14/iostream:41,
                 from a.cc:1:
/usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]'
  299 |       tie() const
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:299:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_ios.h:311:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie(std::basic_ostream<_CharT, _Traits>*) [with _CharT = char; _Traits = std::char_traits<char>]'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:311:43: note:   no known conversion for argument 1 from 'bool' to 'std::basic_ostream<char>*'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~
a.cc:57:33: error: no matching function for call to 'std::basic_ostream<char>::tie(bool)'
   57 |         cin.tie(false); cout.tie(false);
      |                         ~~~~~~~~^~~~~~~
/usr/include/c++/14/bits/basic_ios.h:299:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie() const [with _CharT = char; _Traits = std::char_traits<char>]'
  299 |       tie() const
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:299:7: note:   candidate expects 0 arguments, 1 provided
/usr/include/c++/14/bits/basic_ios.h:311:7: note: candidate: 'std::basic_ostream<_CharT, _Traits>* std::basic_ios<_CharT, _Traits>::tie(std::basic_ostream<_CharT, _Traits>*) [with _CharT = char; _Traits = std::char_traits<char>]'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |       ^~~
/usr/include/c++/14/bits/basic_ios.h:311:43: note:   no known conversion for argument 1 from 'bool' to 'std::basic_ostream<char>*'
  311 |       tie(basic_ostream<_CharT, _Traits>* __tiestr)
      |           ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~