博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[NOIP 2016D2T2/Luogu P1600] 天天爱跑步 (LCA+差分)
阅读量:4657 次
发布时间:2019-06-09

本文共 1092 字,大约阅读时间需要 3 分钟。

待填坑

Code

//Luogu P1600 天天爱跑步//Apr,4th,2018//树上差分+LCA#include
#include
#include
using namespace std;long long read(){ long long x=0,f=1; char c=getchar(); while(!isdigit(c)){
if(c=='-') f=-1;c=getchar();} while(isdigit(c)){x=x*10+c-'0';c=getchar();} return x*f;}const int N=300000+100;vector
e[N];int n,m;int fa[N][21],depth[N],T[N];void dfs(int now){ for(int i=1;i<=20;i++) fa[now][i]=fa[fa[now][i-1]][i-1]; for(int i=0;i
=0;i--) if(depth[fa[x][i]]>=depth[y]) x=fa[x][i]; if(x==y) return x; for(int i=20;i>=0;i--) if(fa[x][i]!=fa[y][i]) x=fa[x][i],y=fa[y][i]; return fa[x][0];}struct mark{ int count,num;};vector
mk1[N],mk2[N];int ans[N],MK1[N*10],MK2[N*10];void dfs2(int now){ int rec1=MK1[T[now]+depth[now]],rec2=MK2[T[now]-depth[now]+2*N]; for(int i=0;i
depth[now]) dfs2(e[now][i]); for(int i=0;i
View Code

 

转载于:https://www.cnblogs.com/GoldenPotato/p/8746871.html

你可能感兴趣的文章
[转]基于SAML的单点登录介绍
查看>>
signer information does not match signer information of other classes in the same package
查看>>
安装mysql Install/Remove of the Service Denied!错误的解决办法
查看>>
Docker三大核心概念之镜像
查看>>
笔记:Java Socket
查看>>
poj1275 Cashier Employment
查看>>
css box-sizing以及calc()
查看>>
oracle 批量插入和批量更新
查看>>
2017-2018-2 1723《程序设计与数据结构》第二周作业 总结
查看>>
delete
查看>>
Android 手机卫士--md5加密过程
查看>>
PGM图片格式与代码
查看>>
jsp内置对象-session
查看>>
SLP读书笔记之 n-gram 语言模型
查看>>
前端工程师的基本素养
查看>>
94. Binary Tree Inorder Traversal 二叉树中序遍历
查看>>
Shell脚本之sed详解
查看>>
hdu-1862 EXCEL排序
查看>>
rsync+inotify
查看>>
Mybatis学习(壹)
查看>>