SHARE
TWEET

Untitled

a guest Aug 11th, 2019 85 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. //* AuThOr GaRyMr *//
  2. #include<bits/stdc++.h>
  3. #define rb(a,b,c) for(int a=b;a<=c;++a)
  4. #define rl(a,b,c) for(int a=b;a>=c;--a)
  5. #define niv vector<int>
  6. #define LL long long
  7. #define IT iterator
  8. #define PB(a) push_back(a)
  9. #define II(a,b) make_pair(a,b)
  10. #define FIR first
  11. #define SEC second
  12. #define FREO freopen("check.out","w",stdout)
  13. #define FREO2 freopen("check.out","r",stdin)
  14. #define rep(a,b) for(int a=0;a<b;++a)
  15. #define KEEP while(1)
  16. using namespace std;
  17. const int INF=0x3f3f3f3f;
  18. typedef pair<int,int> mp;
  19. typedef pair<mp,mp> superpair;
  20. int n;
  21. string s[100000+10];
  22. string P,L;
  23. int main(){
  24.     cin>>n;
  25.     rb(i,1,n) cin>>s[i];
  26.     int len=s[1].length();
  27.     string res="";
  28.     cout<<s[1];
  29.     res+=s[1];
  30.     rb(j,2,n){
  31.         len=min(res.length(),s[j].length());
  32.         int OK=0;
  33.         int ojbk;
  34.         P=L="";
  35.         string save;
  36.         rb(i,1,len){
  37.             P+=s[j][i-1];
  38.             save=L;
  39.             L="";
  40.             L+=res[res.length()-i];
  41.             L+=save;
  42.             if(P==L){
  43.                 ojbk=i;
  44.                 OK=1;
  45.             }
  46.         }
  47.         if(!OK){
  48.             res+=s[j];
  49.             cout<<s[j];
  50.         }
  51.         else{
  52.             rb(i,ojbk,s[j].length()-1){
  53.                 putchar(s[j][i]);
  54.                 res+=s[j][i];
  55.             }
  56.         }
  57.     }
  58.     return 0;
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top