Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- //* 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 niv vector<int>
- #define LL long long
- #define IT iterator
- #define PB(a) push_back(a)
- #define II(a,b) make_pair(a,b)
- #define FIR first
- #define SEC second
- #define FREO freopen("check.out","w",stdout)
- #define FREO2 freopen("check.out","r",stdin)
- #define rep(a,b) for(int a=0;a<b;++a)
- #define KEEP while(1)
- using namespace std;
- const int INF=0x3f3f3f3f;
- typedef pair<int,int> mp;
- typedef pair<mp,mp> superpair;
- int n;
- string s[100000+10];
- string P,L;
- int main(){
- cin>>n;
- rb(i,1,n) cin>>s[i];
- int len=s[1].length();
- string res="";
- cout<<s[1];
- res+=s[1];
- rb(j,2,n){
- len=min(res.length(),s[j].length());
- int OK=0;
- int ojbk;
- P=L="";
- string save;
- rb(i,1,len){
- P+=s[j][i-1];
- save=L;
- L="";
- L+=res[res.length()-i];
- L+=save;
- if(P==L){
- ojbk=i;
- OK=1;
- }
- }
- if(!OK){
- res+=s[j];
- cout<<s[j];
- }
- else{
- rb(i,ojbk,s[j].length()-1){
- putchar(s[j][i]);
- res+=s[j][i];
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement