HDU 6165 FFF at Valentine】的更多相关文章

FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 1060    Accepted Submission(s): 506 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any oth…
FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 575    Accepted Submission(s): 281 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any oth…
题目链接 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any other couples. Suddenly, LSH, Boss of FFF Group caught both of them, and locked them into two separate cells of the jail randomly. But as the saying goes:…
题目大意:给出一个有向图,问你这个图中是否对于任意两点\(u,v\),都至少满足\(u\to v\)(\(u\)可到达\(v\),下同)或\(v\to u\)中的一个. 一看就是套路的图论题,我们先把边连起来. 考虑一个很基本的性质:在一个强连通分量的点两两可达 于是肯定先Tarjan缩一波点.然后我们得到了一个DAG 接下来就是考虑是否有两个点(当然是缩点之后的了)互不可达. 这个可以直接跑一边拓扑排序.然后看一下是否在某个时刻有两个点的入度为零即可. CODE #include<cstdio…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=6165 题意:给你一个无环,无重边的有向图,问你任意两点,是否存在路径使得其中一点能到达另一点 解析:强联通后拓扑排序,因为对于每一层来说只能有一个入度为零的点,若存在两个,那么就会存在一对点不可达 #include<iostream> #include<cstdio> #include<cstring> #include<string> #include<…
FFF at Valentine Time Limit: 6000/3000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 730    Accepted Submission(s): 359 Problem Description At Valentine's eve, Shylock and Lucar were enjoying their time as any othe…
[链接]http://acm.hdu.edu.cn/showproblem.php?pid=6165 [题意] 一张有向图,n个点,m条边,保证没有重边和自环.询问任意两个点能否满足任何一方能够到达另外一方. [题解] 用Tarjan算法,先把有向图的强连通分量缩成一个点,缩完点之后,剩下的就是一张有向无环图了. 对其进行拓扑排序.一定要唯一的拓扑排序才能够满足题目的要求. 也即,为一条链的时候. 一旦某个时刻做拓扑排序的队列大小大于1就输出无解 [错的次数] 0 [反思] 在这了写反思 [代码…
虽然题解上说缩点然后判断入度就可以了,然后比赛的时候瞎暴力过了. #include <iostream> #include <cstring> #include <string> #include <queue> #include <vector> #include <map> #include <set> #include <stack> #include <cmath> #include <…
传送门 The Experience of Love Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 221    Accepted Submission(s): 91 Problem Description A girl named Gorwin and a boy named Vivin is a couple. They arriv…
2019 杭电多校 10 1003 题目链接:HDU 6693 比赛链接:2019 Multi-University Training Contest 10 Problem Description Oipotato loves his girlfriend very much. Since Valentine's Day is coming, he decides to buy some presents for her. There are \(n\) presents in the shop…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5174 题目意思:给出 n 个人坐的缆车值,假设有 k 个缆车,缆车值 A[i] 需要满足:A[i−1]<A[i]<A[i+1](1<i<K).现在要求的是,有多少人满足,(他坐的缆车的值 + 他左边缆车的值) % INT_MAX == 他右边缆车的值. 首先好感谢出题者的样例三,否则真的会坑下不少人.即同一部缆车可以坐多个人.由于缆车的值是唯一的,所以可以通过排序先排出缆车的位置.求出…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4727 题目大意:队列里所有人进行报数,要找出报错的那个人 思路:,只要找出序列中与钱一个人的数字差不是1的人即可,但是要注意的是这些人是从一个队列中间截取下来的,所以很有可能第一个人就报错了,一开始没有考虑这种状况所以出错了 #include<cstdio> #include <iostream> using namespace std; int main() { int t,n,an…
The Number Off of FFF Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 602 Accepted Submission(s): 284 Problem Description X soldiers from the famous " *FFF* army" is standing in a line, from…
The Number Off of FFF Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 78    Accepted Submission(s): 36 Problem Description X soldiers from the famous "*FFF* army" is standing in a line, fro…
Description N soldiers from the famous "*FFF* army" is standing in a line, from left to right. o o o o o o o o o o o o o o o o o o /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ /F\ / \ / \ / \ / \ / \ / \ / \ / \ / \ / \ /…
Valentine's Day Time Limit: 2000/2000 MS (Java/Others)    Memory Limit: 524288/524288 K (Java/Others)Total Submission(s): 0    Accepted Submission(s): 0Special Judge Problem Description Oipotato loves his girlfriend very much. Since Valentine's Day i…
/* ** 日期: 2013-9-12 ** 题目大意:有n个数,划分为多个部分,假设M份,每份不能多于L个.每个数有一个h[i], ** 每份最右边的那个数要大于前一份最右边的那个数.设每份最右边的数为b[i], ** 求最大的sum{b[i]² - b[i - 1]},1≤i≤M,其中b[0] = 0. ** 思路:朴素DP为,dp[i]表示以i为结尾的最大划分.那么dp[i] = max{dp[j] - h[j] + h[i]²}, ** 1≤i-j≤L,h[j]<h[i].这种会超时,采…
题意: 有许多物品,每个物品有一定概率让女朋友开心.你想让女朋友开心且只开心一次,让你挑一些物品,使得这个只开心一次的概率最大,求最大概率. 题解: 设物品i让女朋友开心的概率为$p_i$ 若你挑选了1-k共k个物品,则可记女朋友一次都开心不了的概率$w_0=\prod _{i=1}^k (1-p_i)$ 女朋友恰好开心一次的概率$w_1=C_k^1\sum _{i=1}^k \frac{w*p_i}{1-p_i}$ 则若挑第k+1个物品,女朋友恰好开心一次的概率为$w^,=w_0*p_k+w_…
链接:http://acm.hdu.edu.cn/showproblem.php?pid=5069 题意:给出n个串,m个询问,每个询问(u,v),求u的一个最长后缀是v的前缀. 思路:离线.将关于u的后缀的查询放在一起,然后将u插入后缀自动机.对于每个v跑一遍即可. struct SAM { SAM *son[4],*pre; int len; int ok; void init() { clr(son,0); pre=0; ok=0; } }; SAM sam[N],*head,*last;…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1520 题目大意:给出n个带权点,他们的关系可以构成一棵树,问从中选出若干个不相邻的点可能得到的最大值为多少 解题思路:简单的树形DP 用dp[i][0]表示以i为根的树上不取i的状态下能得到的最大值 用dp[i][1]表示以i为根的树取i的状态下能得到的最大值 状态转移方程 dp[i][0]=∑(max(dp[son(i)][0],dp[son(i)][1])) dp[i][1]=∑(dp[son(…
Problem Description Queues and Priority Queues are data structures which are known to most computer scientists. The Queue occurs often in our daily life. There are many people lined up at the lunch time. Now we define that ‘f’ , then they are ff, mm,…
Queuing Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 2483    Accepted Submission(s): 1169 Problem Description Queues and Priority Queues are data structures which are known to most computer…
My Brute Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others) Total Submission(s): 941    Accepted Submission(s): 372 Problem Description Seaco is a beautiful girl and likes play a game called "My Brute". Before Va…
Queuing Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1949    Accepted Submission(s): 911 Problem Description Queues and Priority Queues are data structures which are known to most computer s…
HDU.2640 Queuing (矩阵快速幂) 题意分析 不妨令f为1,m为0,那么题目的意思为,求长度为n的01序列,求其中不含111或者101这样串的个数对M取模的值. 用F(n)表示串长为n的合法串的个数. 首先不难通过枚举发现F(0) = 0, F(1) =2, F(3) = 6, F(4) = 9, F(5) = 15.然后引用网上如何求解递推公式的详细解释: 用f(n)表示n个人满足条件的结果,那么如果最后一个人是m的话,那么前n-1个满足条件即可,就是f(n-1): 如果最后一个…
题目地址:HDU 2604 这题仅仅要推出公式来,构造矩阵就非常easy了.问题是推不出公式来..TAT.. 从递推的思路考虑.用f(n)表示n个人满足条件的结果.假设最后一个是m则前n-1人能够随意排列,有f(n-1)种:假设是f,则考虑后两位mf和ff,没有一定满足或者一定不满足的状态,所以继续考虑一位,考虑后三位mmf, fmf, mff, fff,当中fmf和fff不符合条件.假设是mmf,则前n-3种能够随意排列,有f(n-3)种.假设是mff.则继续往前考虑一位.假设是fmff不符合…
转自wdd :http://blog.csdn.net/u010535824/article/details/38540835 题目链接:hdu 4778 状压DP 用DP[i]表示从i状态选到结束得到的最大值 代码也来自wdd /****************************************************** * File Name: b.cpp * Author: kojimai * Creater Time:2014年08月13日 星期三 11时42分53秒 *…
链接:传送门 题意:一个队列是由字母 f 和 m 组成的,队列长度为 L,那么这个队列的排列数为 2^L 现在定义一个E-queue,即队列排列中是不含有 fmf or fff ,然后问长度为L的E-queue的个数 % M 思路: 这道题的关键是找到递推关系!递推关系为:Fn = Fn-1 + Fn-3 + Fn-4,与HDU1575简直一模一样,然后直接矩阵快速幂就OK了 HDU 1575 题解链接 递推关系式不好找,我们可以将字母 f m 分别看为 1 0,给出一个长度L,排列数是为 2^…
At Valentine's eve, Shylock and Lucar were enjoying their time as any other couples. Suddenly, LSH, Boss of FFF Group caught both of them, and locked them into two separate cells of the jail randomly. But as the saying goes: There is always a way out…
题 O∧O http://acm.hdu.edu.cn/showproblem.php?pid=6074 2017 Multi-University Training Contest - Team 4 - 1008 解 fread真是其乐无穷呀! 对于每个给出的ai,bi,ci,di,wi,记ai,bi的LCA为pi, 记ci,di的LCA为qi, 首先根据wi来排序这些电话线 使用并查集 首先把ai到pi路径上未加入pi集合的点加入pi集合,然后把bi到pi路径上未加入pi集合的点加入pi集合…