关于数组清空方式

P8306 【模板】字典树

Treap_Kongzs @ 2024-07-27 22:33:48

省流:memset的本题写法是

memset(cnt,0,sizeof(int)*idx*2)

其实你写for也可以

更不要像我这个蒟蒻 of 工程转er这样qwq(保留核心代码)

笑点解析:C++语言特性

struct trie
{
    int children[maxn][62];
    int cnt[maxn];
    int id;

    void insert(string s);
    int find(string s);
};

void trie::insert(string s)
{
    //It is right,so I deleted
}

int trie::find(string s)
{
    //It is right,so I deleted
}

int main()
{
    int t=0,n=0,m=0;
    string s;
    cin>>t;
    for()//at t
    {
        cin>>n>>m;
        trie* tries=new trie;//did you see?

        for(int j=1;j<=n;j++)
        {
            cin>>s;
            tries->insert(s);//did you see?
        }
        for(int j=1;j<=m;j++)
        {
            cin>>s;
            cout<<tries->find(s);//did you see?
            if(j<m)cout<<endl;
        }
        delete tries;//did you see?
        if(i<t)cout<<endl;
    }
    return 0;
}

|