LG3565 [POI2014]HOT-Hotels】的更多相关文章

题意 有一个树形结构,每条边的长度相同,任意两个节点可以相互到达.选3个点.两两距离相等.有多少种方案? 1≤n≤5 000 分析 参照小塘空明的题解. 很明显到一个点距离相等的三个点两两之间距离相等. 所以我们枚举该点,对子树进行暴力统计,注意统计的顺序 时间复杂度\(O(n^2)\) 代码 #include<bits/stdc++.h> #define rg register #define il inline #define co const template<class T>…
题目链接 http://acm.hdu.edu.cn/showproblem.php?pid=5992 Problem Description There are N hotels all over the world. Each hotel has a location and a price. M guests want to find a hotel with an acceptable price and a minimum distance from their locations.…
题目链接: Finding Hotels Time Limit: 2000/1000 MS (Java/Others)     Memory Limit: 102400/102400 K (Java/Others) Problem Description There are N hotels all over the world. Each hotel has a location and a price. M guests want to find a hotel with an accept…
3524: [Poi2014]Couriers Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 1892  Solved: 683[Submit][Status][Discuss] Description 给一个长度为n的序列a.1≤a[i]≤n.m组询问,每次询问一个区间[l,r],是否存在一个数在[l,r]中出现的次数大于(r-l+1)/2.如果存在,输出这个数,否则输出0. Input 第一行两个数n,m.第二行n个数,a[i].接下来m行,…
3524: [Poi2014]Couriers Time Limit: 20 Sec  Memory Limit: 256 MBSubmit: 1905  Solved: 691[Submit][Status][Discuss] Description 给一个长度为n的序列a.1≤a[i]≤n.m组询问,每次询问一个区间[l,r],是否存在一个数在[l,r]中出现的次数大于(r-l+1)/2.如果存在,输出这个数,否则输出0. Input 第一行两个数n,m.第二行n个数,a[i].接下来m行,…
[BZOJ3872][Poi2014]Ant colony 试题描述 There is an entrance to the ant hill in every chamber with only one corridor leading into (or out of) it. At each entry, there are g groups of m1,m2,...,mg ants respectively. These groups will enter the ant hill one…
暴力/树形DP 要求在树上找出等距三点,求方案数,那么用类似Free Tour2那样的合并方法,可以写出: f[i][j]表示以 i 为根的子树中,距离 i 为 j 的点有多少个: g[i][j]表示以 i 为根的子树中,选出两点,剩下那点距离 i 为 j 的方案数: 那么就可以在搜索完一棵子树的时候用g[i]和f[to[i]]更新答案,然后更新f[i]和g[i],最后还要考虑g[i]和祖先的配对情况…… 但是我写跪了= =后来一看题解……$N\leq 5000$!!!直接$N^2$暴力啊,搞什…
DP/单调队列优化 水题水题水题水题 单调队列优化的线性dp…… WA了8次QAQ,就因为我写队列是[l,r),但是实际操作取队尾元素的时候忘记了……不怎么从队尾取元素嘛……平时都是直接往进放的……还是得记住这个双端队列的错点啊!! //BZOJ 3831 #include<cstdio> #include<cstring> #include<cstdlib> #include<iostream> #include<algorithm> #def…
3831: [Poi2014]Little Bird Time Limit: 20 Sec Memory Limit: 128 MB Submit: 310 Solved: 186 [Submit][Status][Discuss] Description In the Byteotian Line Forest there are trees in a row. On top of the first one, there is a little bird who would like to…
3522: [Poi2014]Hotel Time Limit: 20 Sec  Memory Limit: 128 MBSubmit: 195  Solved: 85[Submit][Status] Description 有一个树形结构的宾馆,n个房间,n-1条无向边,每条边的长度相同,任意两个房间可以相互到达.吉丽要给他的三个妹子各开(一个)房(间).三个妹子住的房间要互不相同(否则要打起来了),为了让吉丽满意,你需要让三个房间两两距离相同. 有多少种方案能让吉丽满意? Input 第一行…