BZOJ1460: Pku2114 Boatherds】的更多相关文章

题目链接:点这里 题目描述:给你一棵n个点的带权有根树,有p个询问,每次询问树中是否存在一条长度为Len的路径,如果是,输出Yes否输出No. 数据范围:\(n\le1e5\,,p\le100\,,长度\le1e5\) Solution: 点分治裸题,没什么好讲的.不过注意当询问0时,答案应该是Yes. Code: #pragma GCC optimize(3) #include<bits/stdc++.h> #define ll long long #define inf 214748364…
Search GO 说明:输入题号直接进入相应题目,如需搜索含数字的题目,请在关键词前加单引号 Problem ID Title Source AC Submit Y 1000 A+B Problem 10983 18765 Y 1036 [ZJOI2008]树的统计Count 5293 13132 Y 1588 [HNOI2002]营业额统计 5056 13607 1001 [BeiJing2006]狼抓兔子 4526 18386 Y 2002 [Hnoi2010]Bounce 弹飞绵羊 43…
Boatherds     Description Boatherds Inc. is a sailing company operating in the country of Trabantustan and offering boat trips on Trabantian rivers. All the rivers originate somewhere in the mountains and on their way down to the lowlands they gradua…
Description Boatherds Inc. is a sailing company operating in the country of Trabantustan and offering boat trips on Trabantian rivers. All the rivers originate somewhere in the mountains and on their way down to the lowlands they gradually join and f…
Boatherds Time Limit: 2000MS Memory Limit: 65536K Description Boatherds Inc. is a sailing company operating in the country of Trabantustan and offering boat trips on Trabantian rivers. All the rivers originate somewhere in the mountains and on their…
http://poj.org/problem?id=2114 (题目链接) 题意 给出一棵树,问是否存在两点间的距离为K. Solution 点分治嘛,跟poj1741差不多.. 然而为什么我调了一个下午..map真是坑死了,各种TLE,以后再也不写了. 代码 // poj2114 #include<algorithm> #include<iostream> #include<cstdlib> #include<cstring> #include<cs…
原题地址:http://poj.org/problem?id=2114 题目大意: 给定一棵点数为\(n~(n \le 10000)\)的无根树,路径上有权值,给出m组询问($m \le 100$),每组询问给出一个k,问树中是否存在长度为k的链.题目是多case 题目分析: 这是第二次写树分治,细节想清楚真的很重要啊...写了两天才写过,接下来说一说算法流程和需要注意的细节吧 首先读入.建图等等等等.. 然后是分治过程: 0.如果当前处理的这棵树的size很小了,调用暴力解决,否则继续执行(这…
求一棵树上是否存在路径长度为K的点对. POJ 1714求得是路径权值<=K的路径条数,这题只需要更改一下统计路径条数的函数即可,如果最终的路径条数大于零,则说明存在这样的路径. 刚开始我以为只要在分治过程中出现过长度为K的就算是找到了,其实不然,因为可能是相同子树里面的两个结点,这个结果显然是错误的. #include <cstdio> #include <cstring> #include <algorithm> #include <vector>…
[题面] 求一颗树上距离为K的点对是否存在 输入数据 n,m 接下来n-1条边a,b,c描述a到b有一条长度为c的路径 接下来m行每行询问一个K 输出数据 对于每个K每行输出一个答案,存在输出“AYE”,否则输出”NAY”(不包含引号) 数据范围 对于30%的数据n<=100 对于60%的数据n<=1000,m<=50 对于100%的数据n<=10000,m<=100,c<=1000,K<=10000000 [思路] 树分治. 离线存储m个询问.分治判断该m个询问…
做广告: #include <stdio.h> int main() { puts("转载请注明出处[vmurder]谢谢"); puts("网址:blog.csdn.net/vmurder/article/details/44308173"); } 题意: 求是否有长度为K的路径. 每组数据 N,表示树有N个点. 然后N行,每行若干个数对(a,b)(a,b),当中第i行时表示i到a有一条长为b的无向边.输入到0截止. 然后若干个数表示K,每一个数输出下…