HDU 4776 (字典树)

手把手教你用示波器搞定PCIe 5.0 REFCLK时钟信号测量(附完整参数解读) 本文详细介绍了如何使用示波器进行PCIe 5.0 REFCLK时钟信号测量,包括示波器与探头的选择、关键参数的测量方法及解读,以及实战中的常见问题与解决方案。通过手把手教学和完整参数解读,帮助硬件工程师高效完成时钟信号测量,确保系统稳定性。 阅读详情

题意:

        一棵树,有边权,路径价值为所有边权异或的值,m次查询,每次查询第k大的路径的价值

标题思路:

        从1dfs出其他点到1的路径的值,我们发现任意一条路径可以表示为两个值相异或,这样题目就变成了n个数,问任意两个异或的值中的第k大。
        先将这n个数放到字典树中,我们再将这n个数分别跑一次字典树,这样能跑出当前最大的值,把这些值放到优先队列中,此刻最大的值就是异或出的最大的值,然后我们把这个点拿出来,再跑一次字典树,去寻找第二大的值,这样优先队列中最大的值就是第二大的,这样不断重复就能得到前k大了,复杂度O(nlogn2)O(nlogn^2 )O(nlogn2)

错误及反思:

代码:

#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define mst(x,a) memset(x,a,sizeof(x))
#define all(x) (x).begin(),(x).end()
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
typedef pair<int,int> pii;
typedef long long ll;
typedef vector<int> vi;
#define fi first
#define se second
#define sz(x) ((int)x.size())
#define cl(x) x.clear()
const int mod = 1000000007;
const int N = 100010;
void MOD(ll &a){if(a>=mod) a-=mod;}
void MOD(ll &a,ll c){if(a>=c) a-=c;}
void ADD(ll &a,ll b){ a+=b; MOD(a);}
void ADD(ll &a,ll b,ll c){a+=b;MOD(a,c);}
ll qpow(ll a,ll b){ll ans=1;while(b){if(b&1)ans=ans*a%mod;a=a*a%mod;b/=2;}return ans;}
ll qpow(ll a,ll b,ll c){ll ans=1;while(b){if(b&1)ans=ans*a%c;a=a*a%c;b/=2;}return ans;}

int tot,head[N],n;
struct EDGE{
    int to,nex;
    ll val;
}e[N*2];

ll a[N];

void addedge(int u,int v,ll x){
    e[tot].to=v;
    e[tot].val=x;
    e[tot].nex=head[u];
    head[u]=tot++;
}

int nex[N*62][2],cnt[N*62];
int root,sz;

int newnode(){
    nex[sz][0]=nex[sz][1]=cnt[sz]=0;
    return sz++;
}

void Insert(ll x){
    int now=root;
    cnt[now]++;
    for(int i=61;i>=0;i--){
        if(x&(1ll<<i)){
            if(!nex[now][1]) nex[now][1]=newnode();
            now=nex[now][1];
        }
        else{
            if(!nex[now][0]) nex[now][0]=newnode();
            now=nex[now][0];
        }
        cnt[now]++;
    }
}

ll query(ll x,int k){
    int now=root;
    ll res=0;
    for(int i=61;i>=0;i--){
        if(x&(1ll<<i)){
            if(nex[now][0]&&cnt[nex[now][0]]>=k){
                res+=(1ll<<i);
                now=nex[now][0];
            }
            else{
                if(nex[now][0]) k-=cnt[nex[now][0]];
                now=nex[now][1];
            }
        }
        else{
            if(nex[now][1]&&cnt[nex[now][1]]>=k){
                res+=(1ll<<i);
                now=nex[now][1];
            }
            else{
                if(nex[now][1]) k-=cnt[nex[now][1]];
                now=nex[now][0];
            }
        }
    }
    return res;
}

void dfs(int now,int fa,ll tmp){
    a[now]=tmp;
    for(int i=head[now];i!=-1;i=e[i].nex){
        if(e[i].to==fa) continue;
        dfs(e[i].to,now,tmp^e[i].val);
    }
}

struct si{
    ll val,ori,k;
    bool operator < (const si& shr) const{
        return val<shr.val;
    }
};

priority_queue<si> pq;
ll fin[N*2];

void init(){
    while(!pq.empty()) pq.pop();
    sz=0;
    root=newnode();
    tot=0;
    mst(head,-1);
}
int qus[N];
int main(){
    while(scanf("%d",&n)&&n){
        init();
        for(int i=1;i<n;i++){
            int u,v; ll x;
            scanf("%d%d%lld",&u,&v,&x);
            addedge(u,v,x); addedge(v,u,x);
        }
        dfs(1,1,0);
        for(int i=1;i<=n;i++) Insert(a[i]);

        for(int i=1;i<=n;i++){
            ll x=query(a[i],1);
            pq.push({x,a[i],1});
        }
        int m; scanf("%d",&m);
        int mx=1;
        for(int i=0;i<m;i++){
            scanf("%d",&qus[i]);
            mx=max(mx,qus[i]);
        }
        for(int i=1;i<=mx;i++){
            if(pq.empty()) break;
            si x=pq.top();
            fin[i]=x.val;
            pq.pop();
            x.k++;
            if(x.k<n){
                x.val=query(x.ori,x.k);
                pq.push(x);
            }
        }
        for(int i=0;i<m;i++){
            if(qus[i]>1ll*n*(n-1))
                printf("-1\n");
            else printf("%lld\n",fin[qus[i]]);
        }
    }
}
博途PLC如何建立与笔记本电脑端的连接?(新手必会) 对S7-1500PLC下载硬件组态或程序,需要建立PC与PLC的连接。 由于S7-1500CPU都具有PN端口,因此建立PC与S7-1500PLC的连接通常使用工业以太网来实现。 1.使用网线连接PC-PLC 使用网线,一端连接PC的以太网卡端口,另一端连接S7-1500CPU的PN端口。 2.设置本机IP地址 2.1 确认本机要设置的IP地址段 本机IP地址要和PLC程序组态IP地址段前三位保持一致,后一位使用组态中没有用到的IP地址段。如下图所示。 那么看了这个图片应该就知道了,地址应该设置成192. 阅读详情

相关推荐

人形机器人五大核心零部件技术解析与国产化实况

人形机器人并非简单机械集成,而是物理、能量、感知、决策与执行五层系统毫秒级协同的复杂体。其性能瓶颈往往不在于整机算法,而深植于谐波减速器的刚度稳定性、无框力矩电机的功率密度与温升控制、六维力传感器的动态响应与温漂抑制、运动控制器的实时OS生态及灵巧手的多指协同精度等底层硬件能力。这些部件共同构成整机68.3%的成本,且国产化率差异显著——谐波减速器达72%,而高精度力矩传感器仍受制于日德厂商。本文聚焦‘谐波减速器’和‘六维力传感器’两大热词,从材料工艺、参数定义、失效模式到产线验证,揭示真正卡脖子的技术关卡

weixin_29065959的博客 412

hdu 4776 Ants(trie+优先队列)

题目链接:hdu 4776 Ants 题意: 给你一棵有n个节点的树,每条边有一个权值ai,现在定义两点直接的距离为路径上经过的边的异或和。 现在有m个询问,每次询问你第k长的路径是多少。 题解: 一开始我想二分+树分治+trie,发现只能做一个询问。- -!。 这里有一个优秀的做法,可以预处理出前k个答案。 首先,这里两点间的距离就是val[i]^val[j],val[i]表示根节...

weixin_30565199的博客 153

2、瑞丽-伯纳德对流的拉格朗日拟序结构(FTLE场结果对比)

在中,我简单比较了瑞丽伯纳德对流的FTLE场,但是因为粒子追踪采用的是欧拉方法,所以精度不是很高, 因此与文献中的结果还是有些差别。下面放一张文献中的FTLE场,参数与上篇文章是一致的,Ra = 1e8;Pr = 1;本文将详细的介绍如何得到这样的图片,好吧,其实也不是很详细。总之,先展示以下我个人的结果。可以看出,上图基本上与文献是一致的,因为这里展示的是瞬时场,所以当然不可能是完全一致,至于提取的LCS结构,我在下面也会提及。本着详细介绍的原则,所以这里我很良心的从流场计算开始介绍。

ambu1230的博客 1792

hdu 4776 Ants 杭州现场赛G题

杭州现场赛的题目,首先求出每个节点到根节点的xor值,那么两个节点路径的xor值就等于他们到根节点的xor值再xor。 那么就会有n*n个xor值,但是题目值要求前面的k个,并且k小于200000. 那么就可以这么搞了,先找xor之后最高位为1的,看看有多少个,如果大于k,那么证明前k大的全部在里面,再找次高位的就可以,否者,把这些数全部找出来并排序,剩下的再在这一位不为一的那里找。 #

yrleep的专栏 2631

从零开始开发AI Agent:基于大模型的智能体实战指南

### 摘要 本文介绍了AI Agent的开发全流程,从基础概念到实际部署,涵盖大模型集成、工具调用和记忆系统构建等核心技术。通过电商客服案例展示实战应用,并提供调试优化与部署方案,最后展望了AI Agent的未来发展方向,帮助开发者快速掌握智能体开发技能。

ghs_gss的博客 4879

飞思卡尔16位单片机(二)——CodeWarrior开发环境搭建及新建、调试工程

一、安装CodeWarrior 飞思卡尔16位单片机的开发环境为CodeWarrior5.1,这个软件安装比较简单,软件的安装文件可以从相应的网站上下载。安装CodeWarrior所需要的电脑的硬件资源也比较宽泛,目前一般的电脑都可以满足这个要求,可以支持win10、win7等操作系统。安装过程按照按照软件的提示一步步操作即可。 二、安装USBDM驱动 USBDM是...

bigmarshal的博客 1万+

HDU 4776 DFS + 字典树

题目链接题意:给出一棵树,树上的每一条边都有权值。定义一条路径的权值是经过的所有边的异或和。求所有路径中第kk的路径的权值是多少。思路: 首先一个经典的转化方式是: 先求出从根节点出发,到所有节点的路径的权值,记a[i]a[i]为根节点到ii节点的路径异或和。则路径uu–&gt;vv的权值可转化为a[u]a[v]a[u]^a[v]原因通过画图可以得到。然后问题转化为: 给你nn个数,任意取两个数进行

新熊君的博客 549

IST——In-System-Test

安全性是自动驾驶平台的关键特性之一,而这些架构中使用的半导体芯片必须保证ISO 26262标准所要求的功能安全方面。为了监控由于现场缺陷导致的故障,在启动和/或关闭期间会自动运行系统内结构测试。当系统内测试(IST,In-System-Test)架构检测到任何永久性缺陷时,驾驶平台会做出响应,以实现系统的故障安全状态。汽车IC采用高质量测试方法进行筛选,以实现接近零的DPPM(每百万缺陷部件)。即使在这样的高测试标准下,由于环境或操作条件的影响,在系统现场运行过程中仍可能出现可靠性缺陷。

weixin_50518899的博客 3218

hdu 4776 Ants Trie树+乱搞

参考:http://www.csdn123.com/html/itweb/20131111/216497.htm 代码写的真心挫,在看了题解的算法后,自己去实现,调了好长时间才弄对。代码能力真是不行,难怪区域赛被虐成狗。。。 算法,是参照以上链接的,不多提,就说下我写的时候遇到的问题: 首先,在找次大的时候,不要写成递归的,我最开始是写递归的,但是死活都是爆栈,只好代

wh2124335的专栏 1236

15、降维算法:原理、实现与应用

本文深入介绍了多种降维算法,包括线性方法如主成分分析(PCA)和线性判别分析(LDA),以及非线性方法如Sammon映射、t分布随机邻域嵌入(t-SNE)和自编码器。文章通过C++库Dlib和Shogun展示了这些算法的具体实现,并结合图像压缩和数据可视化等实际案例,分析了不同算法的适用场景。此外,还探讨了降维算法的选择策略、优化改进方法以及未来发展趋势,为读者提供了全面的技术理解和应用指导。

lemon的博客 120

组态王与DLT645-2007电能表通讯调试总结

组态王与电力协议DLT 645-2007调试总结 DLT 645-2007是多功能电能表通信协议,该标准由中国电力企业联合会2006年提出,该协议为主-从结构的半双工通信方式。手持单元或其它数据终端为主站,多功能电能表为从站。每个多功能电能表均有各自的地址编码。通信链路的建立与解除均由主站发出的信息帧来控制。帧是传送信息的基本单元,每帧由帧起始符、从站地址域、控制码、数据域长度、数据域、帧信息纵向校验码及帧结束符7个域组成,每部分由若干字节组成,帧格式如图1所示。 1.确定设备地址 地址域由 6 个字节构

逍遥子的博客 1万+

hdu 4776 Ants

题意:给出一个n个点的树,任意两个

绝望的乐园 1306

微信小程序 - 引入并使用 Fly.js 请求库(超级详细的教程及运行示例)提供 Fly.js 源码源文件下载,贴心的配置示例及注释,优雅快速的发起 http 网络请求

fly.js请求库官方教程文档,微信小程序封装fly.js请求,在小程序/mpvue中使用flyio发起网络请求的方法,微信小程序中如何使用flyio封装网络请求,微信小程序中如何使用flyio封装网络请求,最好的教程,fly最好的文档教程,微信小程序使用fly接口请求框架,引入fly.js报错,微信小程序中如何使用flyio封装网络请求,微信小程序引入Fly.js请求库,如何在fly中配置请求/响应拦截器,如何在微信小程序中优雅地发送异步请求,请求/响应拦截器,微信小程序-引入并使用F

🏆 前端领域优质创作者 5617

2013杭州赛区Ants hdu4776

题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4776 参见大牛题解http://blog.csdn.net/dslovemz/article/details/15290899。 自己比赛的时候除了枚举每一位之外,就没什么想法了,看了大牛题解,思路才略为明朗。此题的关键还是在于K比较小,1 <= k <= 200000。 ...

dil15358的博客 219

VB摄像头监控

该VB模块可对摄像头捕获的画面进行录像等,可在创建的窗口进行控制

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

HDU 4776 Ants(字典树+优先队列+思维题)

Problem Description   There are some apple trees in a farm. An apple tree can be described as a connected graph which has n nodes and n-1 edges. The apples are the nodes and the branches are the edges

退役的铜牌狗 468

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

HDU 4287 Intelligent IME(字典树数组版)

Intelligent IME Time Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 4776Accepted Submission(s): 2227 Problem Description  ...

weixin_30326745的博客 80

复分析 阿尔福斯(Ahlfors) 第三版答案 英文

答案分为十章,有部分习题没有答案,全英文复分析阿尔福斯(Ahlfors) 第三版答案

HDU2846 简单字典树

由于模式串不一定是以前缀出现,所以普通的字典树插入是不行的。可以考虑将母串的每一个后缀串都插入一遍,就可以达到查询时遍历母串的所有位置为起点,而不是仅仅以前缀的遍历方式。此外还要考虑到诸如样例中的用d去匹配add,按上述方式会产生重复,所以可以考虑在Trie结构中加入id编号,只有在不是同一个id时再进行计数。详情看代码。#include #include #include #include

神様いないの日々 444

hdu 1705 字典树典型应用

Hdu  1075 字符串 这道题用的是字典树,其中有如何建树, 字典树可以方便查找,但是内存消耗大,但是这道题很符合字典树。是一道很好的字典树应用的题。 并且在写代码的过程中,还有很多的细节要处理。不仅仅是建好树就可以解决这道题的。还建好树后还需要处理好字符串, 如何控制读取一串字符中的单个单词到字典树中去比对,替换也是这道题的难点。并且还要注意指针的初始化,和指针型数组的空间的申请。 ...

wangmengfuu的博客 247

hdu1305 字典树水题

题意:      给你一些字符串,然后问你他们中有没有一个串是另一个串的前缀。 思路:       字典树水题,(这种水题如果数据不大(这个题目不知道大不大,题目没说估计 不大),hash下也行,把每个串拆成len个串,然后map容器记录下就行了,不想存也 行,最后迭代一下也能出来),回来说字典树,就是最简单的前缀判断应用,我写的结 构体里面有3个量,n

天使也掉毛 917

HDU - 5390 tree (可持久化字典树+线段树)

题目vj链接 题面: 题意: 给定一棵有根树,根节点为1,节点 iii 的权值为 vivivi。 有以下两种操作: (1) 0 x y ---- 将节点 xxx 的权值改为 yyy (2) 1 x ---- 查询 vx xor vtv_x\space xor\space v_tvx​ xor vt​ 的最大值,其中 t∈path(x,root)t \in path(x,root)t∈path(x,root) 题解: ①、考虑不带修改 vxv_xvx​ 是一个已知的

_Griefs 321

hdu(1305)字典树入门

题目大意:给你一些二进制组成的密码,询问是否可以解码,规定如果这些密码里存在某些二进制密码是另外一些二进制密码的前缀,则不可以解码,如果不是则代表可以解码,以数字9代表当前一组数据输入结束。 字典树的应用,感觉这种数据结构就是个模拟,耗费内存好大啊。 #include #include #include using namespace std; char str[20]; int to

constbh的博客 453

bzoj 3495: PA2010 Riddle 2-sat

bzoj 3495: PA2010 Riddle

Rising_shit的博客 919

HDU 4776 Ants tire+优先队列

【题目大意】 有一棵树,树上一条简单路径

ACMmaxx的专栏 1236

【字符串】hdu4144 Bacon's Cipher

传送门:戳我 题目大意:

Lorry酱的专栏 657

单词数

单词数 Time Limit: 1000ms Case Time Limit: 1000ms Memory Limit: 32768KB 64-bit integer IO format: %I64d      Java class name: Main Submit Status PID: 6216 Font Size: lily的好朋友xiaoou33

随风而逝 746

字典树(HDU1251,1247)

例题 HDU1251统计难题 给你若干个单词,再给出若干次询问,每次询问给出一个字符串,让你求出以这个字符串为前缀的单词总共有多少个 先把所有单词建树,建的过程中顺便把所有前缀数量(也就是结点使用次数)统计出来,查询复杂度为O(len)。 AC代码: int trie[1000010][26]; int ct = 1; //总结点数 int ans[1000010]; //统计每个节点的前缀数量 void Insert(string a) { int p = 0; for (

陈颜的博客 5352
上一篇: CodeChef VLB Vasya and Little Bear (树上莫队)
下一篇: CodeChef QCHEF Chef and Problems (分块)
Roll_Keyboard
博客等级 码龄9年 10粉丝 128原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值