original title link:http://acm.hdu.edu.cn/showproblem.php?pid=1671
Test Instructions: give a lot of phone numbers, if dialing to an existing number, it will be directly out, so that the number is prefixed with this number of all other than the numbers will not dial out, ask whether all the numbers can be dialed.
Analysis: You can directly build a dictionary tree, using a Boolean variable in the
OutputNOYESThere are three ways of doing this topic:① dynamic creation of the trie tree, the benefits of this is to save space, no space redundancy, but the disadvantage is the need to new node multiple times, for this problem, each set of test sample new Times up to 10000 * 10 times, to know that dynamic creation of so many nodes is necessarily over 1000ms, But Maybe,hdu's data compare to water, this method still can AC, but this method must pay att
OutputNOYESTest instructions: Just ask whether there is a serial number in these numbers is the prefix of another string of numbers, a typical trie tree template problem;AC Code:#include#include#include#includeUsingNamespace Std;Constint N=100010;Char Str[N][10];int TNCnt, Trie[N][20],flag, Val[N];voidBuild_checktrie(Char*s,Int V){int Len=Strlen(s), U=0;For(int I=0; I; I++){int num=s[I]-' 0 ';If(!trie[u][num]){For(Int J=0; j10; j++){Trie[CNT][j]=0;}
Phone number viewing statistics submitted question total time limit: 1000 ms memory limit: 65536kb description
For some phone numbers, check whether they are consistent, that is, whether a phone number is the prefix of another phone number. For example:
Emergency 911
Alice 97, 625, 999
Bob 91 12 54 26
In this examp
Phone Number
Time limit:1000ms Memory limit:65536k have questions. Dot here ^_^
Topic DescriptionWe know that if a phone number A is another phone number B's prefix, B is isn't able to be called. For a example, A are 123 while B is 12345, after pressing 123, we call a, and not able to call B.
Given N phone numbers, y
The positive solution is a dictionary tree, the use of linked lists to achieve a data structure, the construction method and purple book on the two-tree similar. Because the memory of this problem is relatively tight, so the memory problem needs to be solved, but if the recursive release of memory will lead to inefficient, the solution is to open a memory pool (array), each update subscript can be reused.#i
Http://acm.hdu.edu.cn/showproblem.php? PID = 1, 1671 Problem descriptiongiven a list of phone numbers, determine if it is consistent in the sense that no number is the prefix of another. Let's say the phone catalogue listed these numbers:
1. Emergency 911
2. Alice 97 625 999
3. Bob 91 12 54 26
In this case, it's not possible to call Bob, because the central wocould direct your call to the emergency line as
Tag:arforon Code ampas reswindowapp private void Stackpanel_tap (object sender, Tappedroutedeventargs e) {//Gets the object is ListBoxItem Listboxi Tem mylistboxitem = (listboxitem) (ListBox. Itemcontainergenerator.containerfromitem (sender as Panel). DataContext)); Find ContentPresenter ContentPresenter mycontentpresenter = findvisualchild Find an element of a type in the visual tree in Windows Phone
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.