| 记录编号 | 
        569048 | 
        评测结果 | 
        AAAAAAAAA | 
    
    
        | 题目名称 | 
        51.[NOIP 2000PJ]单词接龙 | 
        最终得分 | 
        100 | 
            
    
    
        | 用户昵称 | 
         lihaoze | 
        是否通过 | 
        通过 | 
    
    
        | 代码语言 | 
        C++ | 
        运行时间 | 
        1.465 s  | 
    
    
        | 提交时间 | 
        2022-02-14 01:09:14 | 
        内存使用 | 
        1.27 MiB  | 
        
    
    
    
    		显示代码纯文本
		
		#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#define OPEN(_x) freopen(#_x".in", "r", stdin); freopen(#_x".out", "w", stdout)
#define ABS(_x) ((_x)<0?(-(_x)):(_x))
#define MAX(_a, _b) ((_a)<(_b)?(_b):(_a))
#define MIN(_a, _b) ((_a)>(_b)?(_b):(_a))
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
namespace IO{
    template<typename T>
    inline T read() {
        T ret=0, sig=1; char ch=0;
        while(ch<'0'||ch>'9') { if(ch=='-') sig=-1; ch=getchar(); }
        while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); }
        return ret*sig;
    }
    template<typename T>
    inline void read(T &x) {
        T ret=0, sig=1; char ch=0;
        while(ch<'0'||ch>'9') { if(ch=='-') sig=-1; ch=getchar(); }
        while(ch>='0'&&ch<='9') { ret=(ret<<1)+(ret<<3)+ch-'0'; ch=getchar(); }
        x = ret*sig;
    }
    template<typename T>
    inline void write(T x) {
        if(x<0) putchar('-'), x=-x;
        T stk[100], tt=0;
        do stk[tt++]=x%10, x/=10; while(x);
        while(tt) putchar(stk[--tt]+'0');
    }
};
const int N=30;
int times[N];
string t[N], bg;
int n, m, mx;
int check(string x,string q) {
	for(register int i=x.size()-1; i>=0; --i) {
		if(x[i]==q[0]) {
			int l=i;
			for(int j=0;j<q.size();j++){
                if(x[l]==q[j])l++;
                else break;
            }
			if(l==x.size()) return l-i;
		}
	}
	return 0;
}   
void dfs(int a, string x) {
	mx = MAX(mx, (int)x.size()-a);
	for(int i=1; i<=n; i++) {
		if(times[i]==2)continue;
		int len = check(x,t[i]);
		if(!len) continue;
		times[i]++;
		dfs(a+len, x+t[i]);
		times[i]--;
	}
}
int main() {
    OPEN(dcjl);
    IO::read(n);
    for(register int i = 1; i<=n; ++i) cin >> t[i];
    cin >> bg;
    dfs(0, bg);
    IO::write(mx);
    return 0;
}