Table of Contents
Phone List(HDOJ-1671) (tire tree)
Home Backend Development PHP Tutorial Phone List(HDOJ-1671) (tire tree)_PHP tutorial

Phone List(HDOJ-1671) (tire tree)_PHP tutorial

Jul 13, 2016 am 09:54 AM
phone

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>
Copy after login

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/997428.htmlTechArticlePhone List(HDOJ-1671) (tire tree) The correct answer is a dictionary tree, a data structure implemented using a linked list , the construction method is similar to the binary tree in the purple book. Because the memory for this question is relatively small...
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

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

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

What is the difference between cell phone and mobile phone? What is the difference between cell phone and mobile phone? Jan 04, 2021 pm 03:34 PM

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.

Leak reveals Redmi Note 14 Pro camera and display details Leak reveals Redmi Note 14 Pro camera and display details Jun 26, 2024 am 06:52 AM

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

Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Vivo Y300 Pro packs 6,500 mAh battery in a slim 7.69 mm body Sep 07, 2024 am 06:39 AM

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

HMD releases HMD 105 and HMD 110 feature phones with long battery life but lacking Nokia branding HMD releases HMD 105 and HMD 110 feature phones with long battery life but lacking Nokia branding Jun 14, 2024 am 11:24 AM

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

OnePlus reveals some core specs of Ace 3 Pro ahead of June 27 launch OnePlus reveals some core specs of Ace 3 Pro ahead of June 27 launch Jun 24, 2024 pm 10:05 PM

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 Phone (2a) Plus: Refreshed mid-ranger arrives with faster chipset, new colorways Nothing Phone (2a) Plus: Refreshed mid-ranger arrives with faster chipset, new colorways Aug 01, 2024 am 06:50 AM

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 Narzo N61: Entry-level handset debuts with IP54 rating and sub-8 mm thickness Realme Narzo N61: Entry-level handset debuts with IP54 rating and sub-8 mm thickness Jul 30, 2024 pm 07:38 PM

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

Xiaomi Redmi 14C debuts as cheap Android phone with \'premium\' design Xiaomi Redmi 14C debuts as cheap Android phone with \'premium\' design Aug 30, 2024 pm 10:47 PM

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

See all articles