代码:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#define min(a,b) (a) > (b)?(b):(a)
using namespace std;
int n, len = 9999999;
string s[105];
vector<char> v;
int main()
{scanf("%d", &n);getchar();for(int i = 0; i < n; i++) {getline(cin, s[i]);reverse(s[i].begin(), s[i].end());len = min(len, s[i].length());}for(int i = 0; i < len; i++) {int flag = 1;char temp = s[0][i];for(int j = 1; j < n; j++) {if(s[j][i] != temp) {flag = 0;break;}}if(flag == 1) {v.push_back(temp);} else {break;}}if(v.size() == 0) {printf("nai\n");}else {for(int i = v.size()-1; i >= 0; i--){printf("%c", v[i]);}printf("\n");}return 0;
}