Created
September 18, 2013 13:43
-
-
Save soulmachine/6609332 to your computer and use it in GitHub Desktop.
POJ 3630 Phone List, http://poj.org/problem?id=3630
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* POJ 3630 Phone List, http://poj.org/problem?id=3630 */ | |
#define MAXN 10000 /** 输入的编码的最大个数. */ | |
#define CHAR_COUNT 10 /** 字符的种类,也即单个节点的子树的最大个数 */ | |
#define MAX_CODE_LEN 10 /** 编码的最大长度. */ | |
#define MAX_NODE_COUNT (CHAR_COUNT * MAXN + 1) /** 字典树的最大节点个数. */ | |
/* 等价于复制粘贴,这里为了节约篇幅,使用include,在OJ上提交时请用复制粘贴 */ | |
#include "trie_tree.c" /* 见“树->Trie树”这节 */ | |
int main() { | |
int T = 0; // 测试用例编号 | |
trie_tree_t *trie_tree = trie_tree_create(); | |
scanf("%d", &T); | |
while (T--) { | |
int i, n; | |
char line[MAX_CODE_LEN + 1]; // 输入的一行 | |
bool is_legal = true; | |
scanf("%d", &n); | |
trie_tree_clear(trie_tree); | |
for (i = 0; i < n; i++) { | |
scanf("%s", line); | |
if(!trie_tree_insert(trie_tree, line)) | |
is_legal = false; | |
} | |
if (is_legal) printf("YES\n"); | |
else printf("NO\n"); | |
} | |
trie_tree_destroy(trie_tree); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment