HDU
来源:互联网 发布:dota2 mac 编辑:程序博客网 时间:2024/06/15 11:02
高端操作
#include <iostream>#include <cstdio>#include <cstdlib>#include <cstring>#include <string>#include <cmath>#include <set>#include <map>#include <stack>#include <queue>#include <ctype.h>#include <vector>#include <algorithm>#include <sstream>#define PI acos(-1.0)#define in freopen("in.txt", "r", stdin)#define out freopen("out.txt", "w", stdout)using namespace std;typedef long long ll;const int maxn = 500000 + 7, INF = 0x3f3f3f3f;int n;string str[maxn];int main() { ios::sync_with_stdio(0); cin.tie(0); int T; cin >> T; while(T--) { cin >> n; int j = 0; for(int i = 0; i < n; ++i) { cin >> str[i]; if (str[j].length() < str[i].length()) j = i; } bool ok = true; for(int i = 0; i < n; ++i) { if(i != j && str[j].find(str[i]) == string::npos) { ok = false; break; } } if(ok) cout << str[j] << endl; else cout << "No" << endl; } return 0;}