每个点的主席树的root是从其父转移来的。询问的时候用U+V-LCA-FA(LCA)即可。#include#includeusing namespace std;#define N 100001int v[N>1); T[cur].lc=++e; BuildTree(T[cur].lc,l,m); ...
分类:
其他好文 时间:
2015-04-13 20:40:23
阅读次数:
139
【标签】离散化,数据结构,分治,图论
【题意】
You are given a tree with N nodes.
The tree nodes are numbered from 1 to N.
Each node has an integer weight.
We will ask you to perfrom the following operation:
u v :...
分类:
其他好文 时间:
2015-04-08 18:06:15
阅读次数:
184
基础的树链剖分题目,不过是边权,可以向下映射成点权或者按边剖分。
VIEW CODE
#include
#include
#include
#include
#include
#include
using namespace std;
const int mmax=10010;
const int inf=0x3fffffff;
struct edge
{
int st,en,cos...
分类:
其他好文 时间:
2015-04-05 17:35:02
阅读次数:
116
题目链接:点击打开链接
MYQ10 - Mirror Number
A number is called a Mirror number if on lateral inversion, it gives the same number i.e it looks the same in a mirror. For example 101 is a mirror number whi...
分类:
其他好文 时间:
2015-04-01 00:28:20
阅读次数:
196
Description
Alice和Bob在玩一个游戏。有n个石子在这里,Alice和Bob轮流投掷硬币,如果正面朝上,则从n个石子中取出一个石子,否则不做任何事。取到最后一颗石子的人胜利。Alice在投掷硬币时有p的概率投掷出他想投的一面,同样,Bob有q的概率投掷出他相投的一面。
现在Alice先手投掷硬币,假设他们都想赢得游戏,问你Alice胜利的概率为多少。Solution
设f[i]...
分类:
其他好文 时间:
2015-03-31 16:04:05
阅读次数:
195
题目链接:http://acm.hust.edu.cn/vjudge/problem/viewProblem.action?id=32356Given a sequence of n numbers a1, a2, ..., anand a number of d-queries. A d-quer...
分类:
其他好文 时间:
2015-03-28 23:12:30
阅读次数:
238
求多边形的重心。。啥都不说了,代公式。。#includedouble x0,y0,x1,y1,x2,y2,s,as,gx,gy;int t,n;int main(){ scanf("%d",&t); while(t--){ scanf("%d",&n); sc...
分类:
其他好文 时间:
2015-03-16 22:31:38
阅读次数:
148
排序。。就是数据有点坑爹。。#include#include#include#includeusing namespace std;struct sbjjq{ int z,x,c,v,b,q;}a[100005],r;int n,t,i,m;bool pd(sbjjq x,sbjjq y){r...
分类:
其他好文 时间:
2015-03-16 21:10:58
阅读次数:
162
已知三角形重心到三边的距离和其中一边,求面积和重心到垂心的距离。计算几何。。纯数学题#include#includeint t;double x,y,z,a,s,d,r1,r2;int main(){ scanf("%d",&t); while(t--){ scanf("%...
分类:
其他好文 时间:
2015-03-16 16:00:49
阅读次数:
117
题目大意:给你一棵树,有两个操作1.修改一条边的值,2.询问从x到y路径上边的最大值思路:如果树退化成一条链的话线段树就很明显了,然后这题就是套了个树连剖分,调了很久终于调出来第一个模板了 1 #include 2 #include 3 #include 4 #define maxn 100...
分类:
其他好文 时间:
2015-03-15 18:20:59
阅读次数:
103