hdu 3966 Aragorn's Story

App渗透 - 人脸识别登录绕过 一、APP抓包和逆向破解加密算法打开APP是一个登录框抓包后发现参数被加密了使用Jadx脱源码发现,并没有加壳也没有混淆,运气很好根据经验,先搜索Encrypt、Decrypt等关键字,发现在Common.js中有一个encryptData函数定位过去,一套加解密算法都写好了放在这放到浏览器console里面调试,果然没错二、寻找注入点首先测试了一下注入明文:{"userName":"TEST'... 阅读详情

        题意:一棵树,每个节点有初始权值,有p次操作,要么询问某个点的权值,要么修改树上两个节点u-v间路径的权值。

        思路:树链剖分。这是我做的第一道树链剖分题,我对树链剖分的理解是,把树递归地分割成线性(重边优先),按顺序排列起来,最后长度和树的节点数一样。然后就可以利用线段树,对树上的路径进行维护。


#pragma comment(linker, "/STACK:1024000000,1024000000")  
#include<iostream>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<algorithm>
#include<string.h>
#include<cstdio>

using namespace std;

#define maxn 50010

int a[maxn];

int head[maxn];
int next[maxn*2];
int to[maxn*2];

int siz[maxn];	//以i为根的子树的节点数
int dep[maxn];	//节点深度
int top[maxn];	//所在链的顶端节点
int fa[maxn];	//父节点
int son[maxn];	//重儿子
int w[maxn];	//节点在线段树中的位置
int w_1[maxn];
bool vis[maxn];
int pos;
int end;

int n,m,p;

void init(int n){
	for(int i=1;i<=n;i++){
		siz[i]=top[i]=son[i]=0;
		dep[i]=w[i]=w_1[i]=fa[i]=0;
		head[i]=-1;
	}
	pos=0;
	end=0;
}

void addedge(int u,int v){
	to[end]=v,next[end]=head[u],head[u]=end++;  
    to[end]=u,next[end]=head[v],head[v]=end++;  
}

void dfs(int x,int pre){
	vis[x]=1;
	dep[x]=dep[pre]+1;
	fa[x]=pre;
	for(int i=head[x];i!=-1;i=next[i]){
		if(to[i]==pre)continue;
		if(vis[to[i]])continue;
		dfs(to[i],x);
		siz[x]+=siz[to[i]];
		if(son[x]==0)son[x]=to[i];
		else if(siz[son[x]]<siz[to[i]])son[x]=to[i];
	}
	siz[x]++;
}

void dfs2(int x,int pre){
	vis[x]=1;
	pos++;
	w[x]=pos;
	w_1[pos]=x;
	if(son[fa[x]]==x)top[x]=top[fa[x]];
	else top[x]=x;
	//先递归重儿子 
	if(son[x]==0)return;
	dfs2(son[x],x);
	for(int i=head[x];i!=-1;i=next[i]){
		if(to[i]==pre)continue;
		if(to[i]==son[x])continue;
		if(vis[to[i]])continue;
		dfs2(to[i],x);
	}
}

struct node{
	int l,r;
	int val;
	int lazy;
};
node tree[maxn<<2];

void build_tree(int n,int l,int r){
	tree[n].l=l; tree[n].r=r;
	tree[n].val=tree[n].lazy=0;
	if(l==r){
		tree[n].val=a[w_1[l]];
		return;
	}
	
	int mid=(l+r)>>1;
	build_tree(n<<1,l,mid);
	build_tree((n<<1)|1,mid+1,r);
}

void push_down(int x){
	int& add=tree[x].lazy;
	node& lch=tree[x<<1];
	node& rch=tree[(x<<1)|1];
	
	if(lch.l==lch.r)lch.val+=add;
	else lch.lazy+=add;
	if(rch.l==rch.r)rch.val+=add;
	else rch.lazy+=add;
	add=0;
}


void update(int n,int l,int r,int v){
	if(tree[n].l==l&&tree[n].r==r){
		if(l==r){
			tree[n].val+=v;	
		}else{
			tree[n].lazy+=v;
		}
		return;
	}
	if(tree[n].lazy)push_down(n);
	
	int mid=(tree[n].l+tree[n].r)>>1;
	if(r<=mid){
		update(n<<1,l,r,v);
	}else{
		if(l>mid){
			update((n<<1)|1,l,r,v);
		}else{
			update(n<<1,l,mid,v);
			update((n<<1)|1,mid+1,r,v);
		}
	}
}

int query(int n,int pos){
	if(tree[n].l==tree[n].r)return tree[n].val;
	if(tree[n].lazy)push_down(n);
	int mid=(tree[n].l+tree[n].r)>>1;
	if(pos<=mid) return query(n<<1,pos);
	else return query((n<<1)|1,pos);
}

int main(){
	while(cin>>n>>m>>p){
		init(n);
		for(int i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		for(int i=1;i<=m;i++){
			int u,v;
			scanf("%d%d",&u,&v);
			addedge(u,v);
		}
		
		memset(vis,0,sizeof(vis));
		dfs(1,0);
		memset(vis,0,sizeof(vis));
		dfs2(1,0);
		
		build_tree(1,1,n);
		
		char op[2];
		for(int i=1;i<=p;i++){	
			scanf("%s",op);
			if(op[0]=='Q'){
				int c;
				scanf("%d",&c);
				printf("%d\n",query(1,w[c]));
			}else{
				int u,v,k;
				scanf("%d%d%d",&u,&v,&k);
				if(op[0]=='D')k=-k;
				
				//不在一条路径上,上爬 
				while(top[u]!=top[v]){//
					if(dep[top[u]]<dep[top[v]])swap(u,v);
					update(1,w[top[u]],w[u],k);
					u=fa[top[u]];
				}
				//在一条路径上 
				if(w[u]>w[v])swap(u,v);
				update(1,w[u],w[v],k);
				
			}
		}
	}
	return 0;
}


安装Openclaw[本地自动化AI助手]至windows【WSL2模式】系统 Openclaw for Windows 摘要:OpenClaw最佳兼容OpenAI系列模型,推荐使用ChatGPT API(需Auth鉴权),避免K*mi等模型导致的信用卡风险。Windows系统需满足WSL2支持条件(Win11或Win10 1903+版本)。安装需导入自签名根证书或跳过浏览器安全警告,通过离线包部署WSL发行版。使用时通过clawtoken命令获取网关认证令牌,并在浏览器完成设备配对。提供代购ChatGPT Plus账号服务(¥140/月),详细操作指南需加微信群获取文件。(150字) 阅读详情

相关推荐

国产操作系统应用迁移与适配

了解国产操作系统的背景及意义

2301_77609559的博客 2680

hdu 3966 Aragorn's Story 树链剖分

#pragma comment(linker,"/STACK:100000000,100000000") #include #include #include #include #include using namespace std; #define maxn 70007 #define lc u<<1 #define rc u<<1|1 #define ll long long struct

G.D.Retop的专栏 773

Grafana企业版vs开源版:从安装到插件管理的完整对比实测(含离线部署技巧)

本文深入对比Grafana企业版与开源版在安装流程、插件管理和功能限制等方面的差异,特别针对离线部署场景提供实用技巧。通过实测数据源支持、权限管理等核心功能,帮助企业用户做出明智选择,同时详细介绍离线安装和插件签名验证等关键操作。

weixin_29313817的博客 105

HDU 3966 Aragorn's Story

HDU 3966 Aragorn’s Story 原题链接 Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn k...

bug永无止境的博客 154

【origin】负载牵引的Smith圆图

export导出为txt,得到的是幅相值,复制到excel如下图,有多根类似格式的线,只需要复制DE列到origin中。回到sheet,发现新增了选中的一组值,就是解释过后的值。笔者没找到把所有线一起画出的方法,只能蠢一点,一组一组画。而且,箭头所指的位置都变成了Y轴(应该要为X轴)以此类推,把之后的曲线都画完,可以汇总到一个图中。显示以下界面,点击右上圆图,选择解释。会生成新的graph,再重新解释一次。选择第二组线,同样画smith圆图。选中第一组线,选smith圆图。复制到origin,如下图。

乾巽的博客 2920

从Mate到Mate40 Pro+:华为旗舰核心配置演进与选购避坑指南

本文回顾了华为Mate系列从初代到Mate40 Pro+的核心配置演进历程,重点分析了处理器性能、影像系统、屏幕设计及续航快充的技术突破。针对选购需求,提供了区分版本、5G选择及存储配置的实用避坑建议,帮助消费者明智选择华为旗舰机型。

weixin_30015371的博客 494

Aragorn's Story hdu3966

题意:在一棵树上有两种操作 1:对于点x和点y之间的路径上所有的点的权值+k或者-k,2:单点查权值思路:树链剖分模板#include&lt;iostream&gt; #include&lt;cstdio&gt; #include&lt;cstring&gt; #include&lt;cstdlib&gt; #include&lt;cmath&gt; #include&lt;algorithm&g...

qq_41231363的博客 199

TC3XX - MCAL知识点(二十七):SENT Mcal配置及代码实战(单边半字节传输协议)

SENT协议只有一根线,异步传输!Sent协议的全称为Single Edge Nibble Trans .isson,单边半字节传输协议,是一种单线异步串行通信协议。Sent报文包含8个Nibble和一个校准位如图1所示,每一个Nibble数据被编码成PWM方式。设计这种协议的目的是用在与汽车ECU快速交互信息的传感器上,以此来取代低精确度的10bit AD和PWM。Sent是一种点对点的单方向从传感器到控制端的协议,控制器不需要同步信号。

梦想技术家 2272

HDU 3966 Aragorn's Story (树链剖分)

题目地址:HDU 3966 树链剖分模板题。不多说、、 代码如下:#include <iostream> #include <string.h> #include <math.h> #include <queue> #include <algorithm> #include <stdlib.h> #include <map> #include <set> #include <stdio.h> u

scf0920 1315

Raspberry Pi Pico SDK开发-Timer-定时

RP2040 由 Raspberry Pi 设计,具有双核 Arm Cortex-M0+ 处理器和 264KB 内部 RAM,并支持高达 16MB 的片外闪存。 广泛的灵活 I/O 选项包括 I2C、SPI 和独特的可编程 I/O (PIO)。 本实例将演示如何使用Timer的定时功能。

视觉与物联智能 2041

FineReport FCP模拟题五

新建决策报表,设置 移动端 格式,采用绝对布局。数据来源:FRDemo中的订单表/雇员表。

Davina_yu的博客 725

[HDU3966]Aragorn's Story

Time Limit: 10000/3000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Problem Description Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Ara...

dxyinme-Zz 495

姿态传感器/陀螺仪之IIS2DLPC 应用驱动程序设计

* 转换为°C单位 (参考温度为25°C,灵敏度为16 LSB/°C) */

corlin6688的博客 220

hdu3966Aragorn's Story

链接:http://acm.hdu.edu.cn/showproblem.php?pid=3966 题意:给定一棵树,3中操作:A:给u->v的路径上所有点点权+k。B:给u->v的路径上所有点点权-k。C:求节点u的点权。 分析:树链剖分+树状数组维护。 代码: #include #include #include #include #include #include #include

Fsss 331

Outlook Express 6 (OE6) for Win7/Win8/Win10

英文版 Outlook Express6.0, 兼容Win7/Win10/WinXP,解压就可用。

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

hdu3966 Aragorn's Story 树链剖分

题意:n个点构成的树,每个点都有一个权值。有三种操作: 1. I  a b  k 使a到b路径中所有点的点权增加k 2.  D a b k 使a到b路径中的 所有点的点权减去k  3. Q  c 查询点c的权值。 思路:树链剖分。剖分后,成段更新,单点查询,详见代码: /*********************************************************

AC_kereo的专栏 870

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

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

HDU 3966 Aragorn's Story 树链剖分

Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 9349    Accepted Submission(s): 2445 Problem Description Our prota

窦小雨的小点子 376

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

HDU3966 Aragorn's Story 树链剖分

裸地不能在裸的树链剖分了,col忘记清空,狂wa一小时。 本来想学LINK CUT TREE的,考试接踵,做题状态全无。== ==暂时顺延了 Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submis

1200

HDU 3966 Aragorn's Story 树链剖分模板

题目:http://acm.hdu.edu.cn/showproblem.php?pid=3966 题解: #include #include #include #include using namespace std; #define MAXN 50010 #define L(u) (u<<1) #define R(u) (u<<1|1) //写在类里面爆栈 int n, m, q; i

3979

树链剖分+线段树 hdu3966 Aragorn's Story

传送门:点击打开链接 题意:路径更新,单点查询 思路:线段树+树链剖分,这里其实不需要懒惰标记也是可以做的 #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define fuck(x) c

qwb的博客 956

HDU - 3966 Aragorn's Story

Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the enemy has N camps ou...

slass-mot-odet 426

HDU - 3966 Aragorn's Story(树链剖分)

题目传送门:HDU - 3966 Aragorn's Story 题目大意: 存在一个树,树上每个节点为一个阵营,阵营中存在敌人,现在要进行以下操作 I C1 C2 K :将阵营C1到阵营C2路径经过的每个阵营的人数+k D C1 C2 K :将阵营C1到阵营C2路径经过的每个阵营的人数-k Q C:查询阵营C中的人数。 分析: 点权树链剖分,线段树维护区间和即可,单...

weixin_33971205的博客 84

[hdu3966]Aragorn's Story

传送门 题目描述 Our protagonist is the handsome human prince Aragorn comes from The Lord of the Rings. One day Aragorn finds a lot of enemies who want to invade his kingdom. As Aragorn knows, the enemy ...

weixin_30249203的博客 78

HDU3966 Aragorn's Story

HDU3966 Aragorn's Story Time Limit: 10000/3000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 605Accepted Submission(s): 160 Problem Description Our protagoni...

weixin_30809173的博客 86
上一篇: hdu 3572 Task Schedule
下一篇: 模板-树链剖分
squee_spoon
博客等级 码龄14年 61粉丝 455原创
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值