AtCoder Beginner Contest 133 F.Colorful Tree(欧拉序+线段树)

Atcoder beginner contest 112(水题大赛) 第一次打atcoder,当时并不清楚beginner是个啥水平,以为和cf的div2一个水准,打开一看……我TM这是什么鬼 AB甚至不如2001普及组…… AB过水,跳过 C 题意:一个金字塔上的每一个点有一个坐标和一个高度,金字塔有一个中心坐标和塔高,给出每个点的高度计算公式 给你n个点的信息(高度,坐标),求高度、Cx和Cy,n , Cx, Cy <= 100 就是类似于... 阅读详情

题目

n(n<=1e5)个点的树,第i条边有u,v,c,d,u和v为边的两端,c为色号,d为边长

q(q<=1e5)个询问,第j次询问x,y,u,v,即把色号为x的所有边权都改成y之后,询问u到v的距离

思路来源

https://atcoder.jp/contests/abc133/submissions/6298312

题解

离线,把所有颜色为i的树边加到col[i]里,把所有颜色为j的询问加到color[j]里,

预处理点欧拉序,边欧拉序,用RMQ来解决LCA,sum[]维护当前点到根的链和

处理颜色i的询问时,ans=两条链之和-两条链上原颜色i树边之和+两条链上颜色i的边的个数*新改的值

做法,先把i的树边的条数插到bit1上,边权插到树状数组bit2上,

bit1中统计两条链上颜色i的边的个数,乘上新改的值v,从答案中减去

bit2中统计一下两条链上原颜色i树边之和,加到答案中

统计完之后,在BIT里把刚插入的颜色对应的边删掉,从而处理下一种颜色

 

本来在考虑,边是离散的,该如何解决,

现在了解到,边在欧拉序中也是对应一段区间的;像树剖一样,把边给远根节点,其欧拉序同远端节点

第i条边(连接u和v,且v是远根节点),入的时间戳同ID[v],出的时间戳同v出的时间戳

那么由于v出了之后,下一个出的就是u,这里不妨+1,变闭区间为开区间,i实际存在的为[in[i],out[i])

代码

#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int N=1e5+10; 
const int lg=18;
int n,q;
int a,b,c,d,y,U,V,fa,ID;
int tmp,num,len1,len2;
int pos[N],ans[N],sum[N];//欧拉序中对应编号 答案 链上的和 
int bit1[N*2],bit2[N*2];//树按颜色建一棵 按查询建一棵 
int dep[N],dis[N];//点的深度 实际边边权
int head[N],v[N*2],nex[N*2],id[N*2],cnt;
int in[N],out[N];
int dfn[N*2],tot;
int dp[N*2][lg];
//欧拉序 dfn点戳 in out边戳 第i条边[in,out)
struct query{int id,y,u,v;};
vector<int>col[N];//把树边放入对应颜色 
vector<query>color[N];//把询问放入对应颜色 
int mn(int u,int v){if(dep[u]<dep[v])return u;else return v;};
void link(int x,int y,int i){v[++cnt]=y;nex[cnt]=head[x];id[cnt]=i;head[x]=cnt;}
void add(int *tr,int x,int v){for(int i=x;i<=tot;i+=i&-i)tr[i]+=v;}
int ask(int *tr,int x){int ans=0;for(int i=x;i>0;i-=i&-i)ans+=tr[i];return ans;}
void dfs(int u,int fa,int d)
{
	dfn[++tot]=u;
	pos[u]=tot;
	dep[u]=d;
	for(int i=head[u];i;i=nex[i])
	{
		int to=v[i],num=id[i],w=dis[num];//边的真实编号 
		if(to==fa)continue;
		in[num]=tot+1;//归远端节点 即下一个搜的节点 
		sum[to]=sum[u]+w;
		dfs(to,u,d+1);
		dfn[++tot]=u;
		out[num]=tot;
	}
}
void init(int up)
{
	for(int i=1;i<=up;++i)
	dp[i][0]=dfn[i];
	for(int len=1;(1<<len)<=up;++len)
	for(int i=1;i+(1<<len)-1<=up;++i)
	dp[i][len]=mn(dp[i][len-1],dp[i+(1<<(len-1))][len-1]);
} 
int lca(int u,int v)
{
	int l=pos[u],r=pos[v];
	if(l==r)return dp[l][0]; 
	if(l>r)swap(l,r);
	int k=log(r-l+1)/log(2);
	return mn(dp[l][k],dp[r-(1<<k)+1][k]);
}
int main()
{
	scanf("%d%d",&n,&q);
	for(int i=1;i<n;++i)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		link(a,b,i);link(b,a,i);
		col[c].pb(i);dis[i]=d;
	}
	dfs(1,-1,0); 
	init(tot);
	for(int i=1;i<=q;++i)
	{
		scanf("%d%d%d%d",&a,&b,&c,&d);
		color[a].pb(query{i,b,c,d});
	}
	for(int i=1;i<n;++i)
	{
		if(!color[i].size())continue;//没有询问 
		len1=col[i].size();
		for(int j=0;j<len1;++j)
		{
			num=col[i][j];
			add(bit1,in[num],1);
			add(bit1,out[num],-1);
			add(bit2,in[num],dis[num]);
			add(bit2,out[num],-dis[num]);
		}
		len2=color[i].size();
		for(int j=0;j<len2;++j)
		{
			ID=color[i][j].id;y=color[i][j].y;
			U=color[i][j].u;V=color[i][j].v;
			fa=lca(U,V);
			tmp=sum[U]+sum[V]-2*sum[fa];
			tmp-=(ask(bit2,pos[U])+ask(bit2,pos[V])-2*ask(bit2,pos[fa]));
			tmp+=y*(ask(bit1,pos[U])+ask(bit1,pos[V])-2*ask(bit1,pos[fa]));
			ans[ID]=tmp;
		}
		for(int j=0;j<len1;++j)
		{
			num=col[i][j];
			add(bit1,in[num],-1);
			add(bit1,out[num],1);
			add(bit2,in[num],-dis[num]);
			add(bit2,out[num],dis[num]);
		}
	}
	for(int i=1;i<=q;++i)
	printf("%d\n",ans[i]);
	return 0;
}

 

告别龟速计算!用Python的fengwo模块5分钟搞定通达信COST/WINNER函数(附完整代码) 本文介绍如何使用Python的fengwo模块高效复现通达信的COST和WINNER函数,解决量化交易中的计算精度和性能问题。通过C++核心算法和多线程优化,计算速度提升显著,误差低于0.5%,并支持与通达信DLL无缝集成,适用于实盘交易策略开发。 阅读详情

相关推荐

LM Studio中文版零基础入门:从安装到模型下载的保姆级教程(附国内镜像源配置)

本文提供LM Studio中文版的零基础入门教程,涵盖从软件安装、中文界面切换到国内镜像源配置的全流程。特别针对模型下载速度慢的问题,详细介绍了如何通过修改配置文件使用国内镜像站,并推荐适合新手的入门模型及硬件配置建议,帮助用户快速上手本地大模型运行。

pz890123456的博客 2653

AtCoder Beginner Contest 133 F Colorful Tree

Colorful Tree 思路: 如果强制在线的化可以用树链剖分。 但这道题不强制在线,那么就可以将询问进行差分,最后dfs时再计算每个答案的修改值, 只要维护两个数组就可以了,分别表示根节点到当前节点某个颜色的个数和某个颜色长度和 代码: #pragma GCC optimize(2) #pragma GCC optimize(3) #pragma GCC opt...

weixin_30872789的博客 194

SAR学习笔记后续-phased工具箱介绍

摘要:相控阵雷达介绍,基于仿真对MATLAB中phased工具箱进行了详细介绍

yjh_2019的博客 1万+

Codeforces1528 C. Trees of Tranquillity(欧拉序性质,树链dfs,set+分类讨论维护最大不相交线段数)

题意: 解法: 容易发现团在树1中,一定是根到某个叶子的树链,上面的点的子集. 还需要满足选定子集在树2中没有祖先关系. 祖先关系可以用树2的欧拉序判断, 如果x是v的祖先,那么L[x]<=L[v]且R[x]>=R[v]. 将每个点的欧拉序看成线段[L[x],R[x]], 那么满足条件的子集,一定两两不相交, 不满足条件的子集,则存在线段包含线段的情况. --- ps:欧拉序形成的线段,相交时一定是包含关系,一定不存在不包含的相交关系. --- 因此线段图一定是这样的(曲线代表线段的

zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz 772

ArcGIS Pro中如何批量替换数据源

不知您是否遇到过下面情况:ArcGIS Pro的Map/Scene中所引用的数据源被移动或重命名了,导致Map/Scene中找不到之前的数据,出现红色叹号;已有一个Map模板文件,图层的样式符号都是设置好的,想批量设置成另外一个数据源,复用该模板文件中的样式符号。 如果您在ArcGIS Pro的使用过程中遇到了上面情况,那么可以参考本篇文章,本文以图层存储在同一GDB中为例介绍。 情况一:Map中已有图层的数据源被移动了 原始Map长这样: 当数据源位置改变之后,显示找不到数据源的红色叹号: 这时如果右

xinying180的博客 7956

数字信号处理实验:信号谱分析与FFT算法的应用

​ (1)给定信号为 ,其中a为42,b为1。理论分析信号 的频率成分。 (2)分别采用采样频率为 , , , 对 进行采样,其中 , , , ,根据是否满足采样定理要求分析四种采样频率下频谱的分布,在满足采样定理情况下做频谱分析。 (3)任意生成两组有限长信号,对信号分别进行直接卷积和FFT算法求卷积,并分析圆周卷积与线性卷积的关系。

m0_56324525的博客 3208

D. Rush Morning(欧拉序+线段树) 树的动态直径

Chiang loves cooking. There are N markets in her city. And there are N - 1 roads which make every market approachable from each other. Chiang always goes to buy food in morning. Due to limited time in morning, she starts from one market, passes every mark

weixin_62887323的博客 1497

Floyd (弗洛伊德)算法简述

Floyd在1962年由Robert Floyd以其当前公认的形式出版。算法作为三个嵌套for循环的现代公式首先由Peter Ingerman在1962年描述。Floyd 算法是解决图论问题的比较经典的算法,是解决给定的加权图中顶点间的最短路径的一种算法,可以正确处理有向图的最短路径问题。

慕羽★的博客 2万+

AtCoder Beginner Contest 133题解

AtCoder Beginner Contest 133 A.T or T ◇题目传送门◆ 题目大意 给定三个数n,a,bn,a,bn,a,b要求输出n×an\times an×a和bbb中较小的一个。 分析 简单题,用if语句判断一下就是了。 参考代码 #include<cstdio> #include<algorithm> using namespace std; i...

IDDFS 716

如何通过插值法计算cell delay?

插值法的公式:Z = A + B * X + C * Y + D * X * Y,其中X为input transition,Y为output load,A、B、C、D为四个参数,Z为delay值。从而得到Z=-0.086176 + 11.5493 * x + 0.65917 * y - 24.859 * x * y,当X=0.014930、Y=0.296311时,得到Z=0.1716ns。从而得到A = 0.08075,B = 3.47539,C = 0.04008,D = 0.01648。

芯冰乐 1080

Google Earth Engine(GEE)——将sentinel - 2影像所有波段重采样到10m分辨率 (resample 和 projection的使用)

影像重投影是将一个影像从一个坐标系投影到另一个坐标系的过程。这通常涉及到将像素从一个平面坐标系变换到另一个平面坐标系。这可以用于许多应用中,例如建立数字高程模型(DEM)和地图制图。影像重投影通常需要进行数学计算,包括转换矩阵和插值算法,以确保像素值的准确性和精度。这次我们将对哨兵2好数据中20m分辨率的波段,重采样到10m分辨率中,然后同一参与计算。

此星光明博客 3113

AtCoder Beginner Contest 133 E - Virus Tree 2(组合数学)

题意 n个点的树k种颜色,距离不超过2的点对需颜色不同,求方案数 Code(copy) #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> typedef long long LL; const int ...

weixin_30768175的博客 162

【Unity动画优化插件】BT - OptiAnimX —— AAA级动画优化框架深度剖析

BT - OptiAnimX 是一款面向 Unity 的高性能动画优化框架,核心目标是解决多角色动画场景中的性能瓶颈问题。该插件对标《战争机器5》和《巫师3》等 AAA 游戏中的动画优化技术,通过一整套自动化与智能化的优化策略,将动画性能提升与视觉质量控制结合在一起。它适用于从移动端、VR 到高端 PC 的多平台项目,尤其在“多人角色 + 高频动画”的场景中表现突出,例如 MMO、开放世界、动作游戏等。BT - OptiAnimX 本质上是一套“动画性能调度系统”,而不仅仅是优化工具。

2403_88403568的博客 437

poj2513—并查集+欧拉回路+线段树

Description You are given a bunch of wooden sticks. Each endpoint of each stick is colored with some color. Is it possible to align the sticks in a straight line such that the colors of the endpo

qq_21820377的专栏 433

深度学习工具包 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")

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

[2017纪中11-1]荒诞 欧拉序+状压DP

题面 题解 太巧妙了。。。图上还能DP。。。 代码:#include<iostream> #include<cstdio> #include<cstring> #define chkmin(a,b) a=min(a,b) using namespace std; const int maxn=100010; int n,m,c[maxn],d[maxn],f[12][60000],ans=0,

DOFYPXY的博客 529

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

Atcoder beginner contest(ABC) 133 E题解

Description 给定一个nnn个节点的树。现在你拥有kkk种颜色,你要用这些颜色给树上的每个节点染色,使得任何两个距离不大于222的不同节点所被染的颜色不同。 由于答案可能过大,请将其对109+710^9+7109+7取模。 Solution 不管各位大佬有多强一眼看穿这题,但是本蒟蒻没有这个本事。于是,我从宏观想,一直向下剖析,最终得到了正解。 于是,这篇题解将会变得格外详细。 Part...

Cherrt的博客 908

温度PID控制PLC程序

温度PID稳定控制程序,适用于欧姆龙PLC,对其他PLC也具有很大参考价值

HDU 4836 The Query on the Tree (欧拉序列,线段树,动态树)

The Query on the Tree Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 197    Accepted Submission(s): 91 Problem Description   度度熊最近

LHYL 1709

AtCoder Beginner Contest 133

Task Name Time Limit Memory Limit A T or T 2 sec 1024 MB Submit B Good Distance 2 sec 1024 MB Submit C Remainder Minimization 2019 2 sec 1024 MB ...

pxlsdz的博客 718

【AtCoder - ABC133F】:Colorful Tree【树上莫队 or 树剖+主席树】

题目: AtCoder - ABC133F:Colorful Tree 题意: 给定一颗树,每条边有一个颜色和长度,现在有 Q 次独立的查询,每次先将 u 到 v 的路径上颜色为 x 的边长度修改成 y,然后查询u 到 v 的路径长度 分析: (1)时限给得比较大,最自然的想法是树上莫队,大致过程是先对树跑一个括号序列,然后就可以像普通莫队那样搞了,但是我们需要维护的是边的信息,于是乎...

KobeDuu 617

[codeforces1184A2]Heidi Learns Hashing (Medium)

time limit per test : 2 seconds memory limit per test : 256 megabytes 分数:2100 // 虽然我觉得思维难度还挺高的,像是2500的题,不像普通的2100那么简单 After learning about polynomial hashing, Heidi decided to learn about shift-xor ha...

dxyinme-Zz 368

Heidi Learns Hashing

Heidi Learns Hashing: 这道题其实没有太多的算法要求,其主要是对我们数学能力的考察。 代码如下: #include<iostream> #include<algorithm> #include<cstdio> using namespace std; int main() { long long r; while(cin&gt...

malloch的博客 360

AtCoder Beginner Contest 132 F

F - Small Products 怎么说呢?目前超了自己水平两个档次的题。 第一个档次熟练掌握dpdpdp 第二个档次熟练掌握分块 这道题:参考大佬 要求求相邻元素乘积≤N≤N≤N的序列数。N≤1e9N≤1e9N≤1e9 序列数考虑dpdpdp 显然:dp[i][j]=∑x∗j≤Ndp[i−1][x]dp[i][j]=\sum_{x*j≤N}dp[i-1][x]dp[i][j]=∑x∗j≤N​...

mxYlulu的博客 557

AtCoder Beginner Contest 133 F - Colorful Tree

题意:给出一棵n个点的树,每条边有颜色和边长两个属性,n个询问,每次询问把颜色x的边的边长变为y问u到v的路径长度是多少,询问之间独立。 解法:这道题蛮有意思的。解法参考https://www.cnblogs.com/Tieechal/p/11185912.html这位大佬的,这里说下我的理解。 对于每组询问(x,y,u,v)答案比较显然就是dist(u,v)+(sumlen[x]-...

weixin_30508241的博客 165

BZOJ 4034 [HAOI2015]树上操作(欧拉序+线段树)

题意: 有一棵点数为 N 的树,以点 1 为根,且树点有边权。然后有 M 个 操作,分为三种: 操作 1 :把某个节点 x 的点权增加 a 。 操作 2 :把某个节点 x 为根的子树中所有点的点权都增加 a 。 操作 3 :询问某个节点 x 到根的路径中所有点的点权和。 思路: 处理出这棵树的欧拉序,入栈时为这个点的正权,出栈时为这个点的负权 对于操作1,对x入栈点加a,出栈...

weixin_30568591的博客 139

线段树进阶总结一 DFS序 欧拉序(括号序)

DFS序 前置的几道题 线段树DFS序 1 单点更新 区间查询 https://blog.csdn.net/qq_40831340/article/details/84501232 线段树DFS序 2 区间子树更新 单点查 https://blog.csdn.net/qq_40831340/article/details/84501478 以上都是关于统计 跟改子树的 欧拉序 这里我们可以处理出 ...

蒟蒻的最后的倔强 707
上一篇: Helvetic Coding Contest 2019 online mirror A2. Heidi Learns Hashing (Medium)(思维题/2-sat)
下一篇: 牛客小白月赛16 J.小雨坐地铁(最短路/分层图最短路dijkstra+虚点)
小衣同学
博客等级 码龄9年 1444粉丝 995原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

小衣同学

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值
⌂ 换网址