题目描述
C++代码
样例
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
int N;
cin >> N;
vector<string> vc;
for (int i = 0; i <= N; i++)
{
string u;
getline(cin, u);
vc.push_back(u);
}
/*cout << "\n";
for (int i = 0; i <= N; i++)
{
cout << vc[i] << endl;
}*/
string s;
string q;
int ans = 0;
bool vis = true;
for (int i=vc[1].size()-1;i>=0;i--)
{
s += vc[1][i];
ans++;
vis=true;
for (int j = 2; j < vc.size(); j++)
{
int st=vc[j].size();
if(st-ans>=0)
{
if (vc[j][st-ans] != vc[1][i])
{
vis = false;
break;
}
}
else{
vis=false;
break;
}
}
if (!vis)
{
break;
}
}
if(!vis)
{
if(s.size()>0)
{
s.pop_back();
}
}
bool viss=false;
for(int i=s.size()-1;i>=0;i--)
{
if((s[i]>='A'&&s[i]<='Z')||(s[i]>='a'&&s[i]<='z'))
{
viss=true;
break;
}
}
if(viss)
{
for (int i = s.size() - 1; i >= 0; i--)
{
cout << s[i];
}
}
else{
cout << "nai" << endl;
}
return 0;
}