84分TLE求助!!!使用了unorderedmap

P8306 【模板】字典树

ECNUAT_LZX @ 2023-07-27 18:33:32


#include<bits/stdc++.h>
using namespace std;
int n,q,T;
int main(){
    ios::sync_with_stdio(0);
    cin>>T;
    while(T--){
        unordered_map<string,int>mp;
        string st;
        cin>>n>>q;
        for(int i=1;i<=n;i++){
            cin>>st;
            int len=st.size();
            string ins="";
            for(int j=0;j<len;j++){
                ins+=st[j];
                mp[ins]++;
            }
        }
        for(int i=1;i<=q;i++){
            cin>>st;
            cout<<mp[st]<<endl;
        }
    }

    return 0;
}

by Auto_Accepted @ 2023-07-27 18:37:35

这题需要手写trie.


by ECNUAT_LZX @ 2023-07-27 18:46:40

此贴结


by AKPC @ 2023-07-31 11:36:29

@xuyiluo2 乐乐乐乐乐乐乐乐


by Auto_Accepted @ 2023-07-31 11:37:04

@A_Passing_Creeper 你干嘛


by AKPC @ 2023-07-31 11:38:17

@xuyiluo2 %%%%%%%%%%%%%%%%%%%%%%%%

我刚作死用了 unorderedmap


by AKPC @ 2023-07-31 11:38:53

@xuyiluo2 CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCOrz


by asas111 @ 2023-11-24 19:45:18

这题用平板电视的gp_hash_table可以卡过


|