Phone List(HDOJ-1671) (tire tree)_PHP tutorial
Phone List(HDOJ-1671) (tire tree)
The correct solution is a dictionary tree, a data structure implemented using linked lists. The construction method is similar to the binary tree in the purple book. Because the memory for this question is relatively tight, the memory problem needs to be solved. However, recursively releasing the memory will lead to low efficiency. The solution is to open a memory pool (array) and reuse it every time the subscript is updated.
#include<cstdio> #include<cstring> #include<iostream> #include using namespace std; int T,n,k; struct pa{ char s[15]; int len; }; bool cmp(pa a,pa b){ return a.len>b.len; } struct trie{ trie *next[15]; }; trie *root; trie all_trie[1000000]; bool built(char *s,int len) { bool ok = true; trie *p = root, *q; for(int i=0;i<len;i++){ id="s[i]-'0';" int="" p-="">next[id]==NULL) { ok = false; q = &all_trie[k++]; for(int j=0;j<10;j++) q->next[j] = NULL; p->next[id] = q; p = p->next[id]; } else { p = p->next[id]; } } return ok; } int main(){ scanf("%d",&T); while(T--){ scanf("%d",&n); pa s[10005]; k = 0; bool ok = true; root = &all_trie[k++]; for(int i=0;i<10;i++) root->next[i] = NULL; for(int i=0;i<n;i++){ .len="strlen(s[i].s);" else="" i="0;i<n;i++)" int="" ok="false;" pre="" return=""><p> </p></n;i++){></len;i++){></algorithm></iostream></cstring></cstdio>

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Differences: 1. Different meanings of communication. Cell phone refers to a digital cellular mobile phone, and mobile phone refers to a mobile phone. 2. Explain the difference in meaning. Cell phone means mobile phone, and mobile phone means mobile phone. 3. The user groups are different. Cell phone is American English and is widely used in Canada and the United States; mobile phone is British English and is widely used in Europe.

Successors of the Redmi Note 13 series phones are expected to land in about three months. While Xiaomi hasn't said anything about the new lineup, the first few details of the Redmi Note 14 Pro have leaked. This leak comes from Digital Chat Station, a

The Vivo Y300 Pro just got fully revealed, and it's one of the slimmest mid-range Android phones with a large battery. To be exact, the smartphone is only 7.69 mm thick but features a 6,500 mAh battery. This is the same capacity as the recently launc

HMDhasreleasedvariousdevicesoflate,includingseveralNokia-brandedfeaturephones.Forcontext,barelyamonthhasgonebysincethecompanypresentedtheNokia32102024,areincarnationoftheNokia3210tomarkits25thanniversary.Additionally

OnePlus is gearing up to launch the Ace 3 Pro in China. The launch is set for June 27, and the company has just confirmed a couple of core specs of the upcoming Android flagship. As previously speculated, the phone will feature the Snapdragon 8 Gen 3

Nothing just announced the Phone (2a) Plus, less than five months since the release of the vanilla model.In this case, the Plus moniker doesn't indicate a larger form factor, but rather a refresh with slightly bumped specs and some new colorways. The

Realme just announced the Narzo N61, its newest entry-level handset with an IP54 rating. It features a 6.74-inch IPS display with a resolution of 1,600 × 720, up to 90 Hz refresh rate, and 560 nits peak brightness. The phone is powered by a 12 nm-bui

After rounds of leaks, Xiaomi has made the Redmi 14C official. As a successor to last year's affordable Redmi 13C, the new phone brings a good number of changes. Among all is a new design, which the company is saying offers a "premium" outl
