PAT1077. Kuchiguse (20)

#include <iostream>
#include <vector>
#include <sstream>
using namespace std;

int n;
string c[100];
string res;
int fir=1;
int ok=0;
string line;
int main()
{
	cin>>n;
	getline(cin,line);
	for(int i=0;i<n;i++){
		ok=0;
		getline(cin,line);
		c[i]=line;
		int p=res.size()-1,q=c[i].size()-1;
		while(p>=0&&q>=0){
			if(res[p]==c[i][q]){
				p--;q--;
			}else{
				break;
			}
		}
		if(fir){
			res=c[i];
			fir=0;
		}else{
			res=c[i].substr(q+1);
		}
	}
	if(res.size()==0) cout<<"nai"<<endl;
	else cout<<res;
	return 0;
}

  

posted @ 2016-03-28 12:26  Yellowman  阅读(147)  评论(0编辑  收藏  举报
TVRBMExqRXlPQzR5TXpjdU1UVTEK\n