1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int cmp(const void *a, const void *b)
{
return strcmp((char*)a, (char*)b);
}
int main(int argc, char *argv[])
{
int num, n;
char tel[10005][11];
scanf("%d", &num);
while (num--) {
int i, flag = 1;
scanf("%d", &n);
for (i = 0; i < n; ++i)
scanf("%s", tel[i]);
qsort(tel, n, sizeof(char) * 11, cmp);
for (i = 1; i < n; ++i) {
int len1 = strlen(tel[i-1]);
int len2 = strlen(tel[i]);
int j = 0;
if (len1 <= len2) {
while(tel[i-1][j] == tel[i][j] && j < len1)
++j;
if (j == len1)
flag = 0;
}
if (!flag)
break;
}
if (flag)
printf("YES\n");
else
printf("NO\n");
}
return 0;
}
|