uvalive 5026 字典树典型

All the big malls need a powerful system for the products retrieval. Now you are employed design a
sub-system: reading the barcodes and return the matching products.
A barcode is an optical machine-readable representation of data, which shows certain data on certain
products. A barcode consists of a series of bars with different widths. In our system, the barcodes
have been scanned and the widths have been recorded. Every consecutive eight bars are considered as
representing the ASCII code of a character, each bar for each bit. Ideally, there should be only two
kinds of widths in the eight bars, and the width of the wider bar is twice of the narrower. The wider bar
indicates 1, while the narrower indicates 0. However, due to the inaccuracy of printing and scanning,
there will be an error of at most 5%. That is, if the pretended exact width is x, you may get a value
in the range [0:95x;1:05x].
For example, the width sequence \10.0 20.0 10.0 10.0 10.0 10.0 10.0 20.0” is a valid barcode of our
system, and it means (01000001)2, which is (65)10 and the corresponding character is \A”. Note that
\10.5 20.1 10.1 10.2 9.9 9.7 10.0 19.9” is also a valid barcode representing the same letter.
You are given the names of all the products and many queries. Every name contains lower-case
letters only, and the length is no more than 30. The queries are represented as barcodes. For each
query, you should decode it to a string S, and report the amount of products whose pre x is S. For
the output may be very large, you only need to output the sum of all the queries for each case.
Input
There are several test cases in the input. The rst line of each case contains two integers N and M
(1 N 10000, 1 M 2000), indicating the number of products and queries. Then N lines follow,
indicating the names of the products. Note that the names may be duplicated. Then M query blocks
follow. The rst line of each query block is an integer K (0 < K 30) indicating the length of the
query, then K lines follow, each line contains 8 positive
oat numbers, indicating the barcode for each
character.
You can assume that the barcodes are always valid, and always represent lower-case letters.
Output
Output one line for each test case, indicating the sum of all the query results as described above.
Explanation for the sample:
There is only one test case. The rst query is \a”, and the answer is 3. The second query is \ap”,
and the answer is 2. The third query is \c”, and the answer is 0. So the total sum is 3+2+0 = 5.
Sample Input
4 3
apple
apple
avatar
book
1
1 2 2 1 1 1 1 2
2
1 2 2 1 1 1 1 2
10.1 20.1 19.9 20.0 10.2 9.8 9.9 10.0
1
1 2 2 1 1 1 2 2
Sample Output
5

题目大意:
先给出所有产品名称, 然后输入查询词, 统计以这个查询词为前缀的产品个数。
查询词的输入比较特殊,是输入条形码的每一条的宽度。
宽度共有两种类型,一种比较宽,一种是窄的, 宽的是窄的长度的两倍。 注意, 如果宽的那个是1, 那么窄的是0。
然后把这个条形码转换成二进制数,宽的位数对应1,窄的对应0.
然后会得到一个ASCII码, 是字母’a’ ~’z’的范围。

典型的字典树

#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstring>
#include <cstdio>
#include <string>
using namespace std;
const int sonnum=26,base='a';
char s1[12],ss[12];

struct Trie
{
    int num;
    bool flag;
    struct Trie *son[sonnum];
    Trie()
    {
        num=1,flag=false;
        memset(son,0,sizeof(son));
    }
};

Trie *NewTrie()
{
    Trie *temp=new Trie;
    return temp;
}

void Insert(Trie *root,char *s)
{
    Trie *temp=root;
    while(*s){
        if(temp->son[*s-base]==NULL)
        {
            temp->son[*s-base]=NewTrie();
        }
        else 
            temp->son[*s-base]->num++;
        temp=temp->son[*s-base];
        s++;
    }
    temp->flag=true;
}

int search(Trie *root,char *s)
{
    Trie *temp=root;
    while(*s)
    {
        if(temp->son[*s-base]==NULL) return 0;
        temp=temp->son[*s-base];
        s++;
    }
    return temp->num;
}

int main()
{
    while(scanf("%d%d",&n,&m))
    {

    Trie *root=NewTrie();
    root->num=0;
    int n, m;
    for(int i=0;i<n;i++)
    {
        scanf(" %s",s1);
        Insert(root,s1);
    }
    int ans=0;
    for(int i=0;i<m;i++)
    {
        int k;
        scanf("%d",&k);
        double wei[8];
        memset(ss,0,sizeof(ss));
        for(int kk=0;kk<k;kk++)
        {
        double sum=0;
         for(int j=0;j<8;j++)
         {
            scanf("%lf",&wei[j]);
            sum+=wei[j];
         }
         int res=0;
         sum/=8.0;
         for(int j=0;j<8;j++)
         {
            if(wei[j]>sum)
                res=res*2+1;
            else res=res*2;
         }
         ss[kk]=res;
        }

         ans+=search(root,ss);
    }
        cout<<ans<<endl;
    }
    return 0;
}
【6层】一字型框架办公楼(含建筑结构图、计算书) 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
深度学习是机器学习的一个子领域,它基于人工神经网络的研究,特别是利用多层次的神经网络来进行学习和模式识别。深度学习模型能够学习数据的高层次特征,这些特征对于图像和语音识别、自然语言处理、医学图像分析等应用至关重要。以下是深度学习的一些关键概念和组成部分: 1. **神经网络(Neural Networks)**:深度学习的基础是人工神经网络,它是由多个层组成的网络结构,包括输入层、隐藏层和输出层。每个层由多个神经元组成,神经元之间通过权重连接。 2. **前馈神经网络(Feedforward Neural Networks)**:这是最常见的神经网络类型,信息从输入层流向隐藏层,最终到达输出层。 3. **卷积神经网络(Convolutional Neural Networks, CNNs)**:这种网络特别适合处理具有网格结构的数据,如图像。它们使用卷积层来提取图像的特征。 4. **循环神经网络(Recurrent Neural Networks, RNNs)**:这种网络能够处理序列数据,如时间序列或自然语言,因为它们具有记忆功能,能够捕捉数据中的时间依赖性。 5. **长短期记忆网络(Long Short-Term Memory, LSTM)**:LSTM 是一种特殊的 RNN,它能够学习长期依赖关系,非常适合复杂的序列预测任务。 6. **生成对抗网络(Generative Adversarial Networks, GANs)**:由两个网络组成,一个生成器和一个判别器,它们相互竞争,生成器生成数据,判别器评估数据的真实性。 7. **深度学习框架**:如 TensorFlow、Keras、PyTorch 等,这些框架提供了构建、训练和部署深度学习模型的工具和库。 8. **激活函数(Activation Functions)**:如 ReLU、Sigmoid、Tanh 等,它们在神经网络中用于添加非线性,使得网络能够学习复杂的函数。 9. **损失函数(Loss Functions)**:用于评估模型的预测与真实值之间的差异,常见的损失函数包括均方误差(MSE)、交叉熵(Cross-Entropy)等。 10. **优化算法(Optimization Algorithms)**:如梯度下降(Gradient Descent)、随机梯度下降(SGD)、Adam 等,用于更新网络权重,以最小化损失函数。 11. **正则化(Regularization)**:技术如 Dropout、L1/L2 正则化等,用于防止模型过拟合。 12. **迁移学习(Transfer Learning)**:利用在一个任务上训练好的模型来提高另一个相关任务的性能。 深度学习在许多领域都取得了显著的成就,但它也面临着一些挑战,如对大量数据的依赖、模型的解释性差、计算资源消耗大等。研究人员正在不断探索新的方法来解决这些问题。
1、资源项目源码均已通过严格测试验证,保证能够正常运行;、 2项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。 1、资源项目源码均已通过严格测试验证,保证能够正常运行; 2、项目问题、技术讨论,可以给博主私信或留言,博主看到后会第一时间与您进行沟通; 3、本项目比较适合计算机领域相关的毕业设计课题、课程作业等使用,尤其对于人工智能、计算机科学与技术等相关专业,更为适合; 4、下载使用后,可先查看README.md或论文文件(如有),本项目仅用作交流学习参考,请切勿用于商业用途。 5、资源来自互联网采集,如有侵权,私聊博主删除。 6、可私信博主看论文后选择购买源代码。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值