//这题需要先将给出的数字当字符串输入,然后再进行字符串的排序,最后在字符串中进行字串的查找!
#include "iostream"
#include "string"
#include "vector"
#include "algorithm"
using namespace std;
int main()
{
int TestCase;
cin >> TestCase;
while (TestCase--)
{
int num;
vector<string> v;
vector<string>::iterator pos;
string temp;
cin >> num;
for (int i = 0; i < num; i++)
{
cin >> temp;
v.push_back(temp);
}
sort(v.begin(), v.end());
int flag = 0;
for (int i = 1; i < num; i++)
{
if (v[i].find(v[i-1]) != -1)//字符串中查找字串,如果字符串中存在其字串,就返回其字串的起始位置,如果不存在就返回值-1!
{
cout << "NO" << endl;
flag = -1;
break;
}
}
if (flag == 0)
cout << "YES" << endl;
}
}
zoj 2876 Phone List
最新推荐文章于 2015-04-28 22:10:43 发布