[Usaco2015 Jan]Moovie Mooving】的更多相关文章

f[i]表示用i集合内的电影可以达到的最长时间 f[i]向f[i|(1<<j)]更新,此时的时间为第j部电影在f[i]前的最晚上映时间 先排序一遍离散化后用前缀最大值解决 时间复杂度$O(n2^n)$ #include<cstdio> #include<algorithm> const int N=20,M=40010; int n,l,i,j,c,d[N],g[N][M],m,q[M],id[M],t[M],f[1<<N],ans=M; inline bo…
题目描述 Bessie is out at the movies. Being mischievous as always, she has decided to hide from Farmer John for L (1 <= L <= 100,000,000) minutes, during which time she wants to watch movies continuously. She has N (1 <= N <= 20) movies to choose…
Description Bessie is out at the movies. Being mischievous as always, she has decided to hide from Farmer John for L (1 <= L <= 100,000,000) minutes, during which time she wants to watch movies continuously. She has N (1 <= N <= 20) movies to…
简单的拓扑图dp.. A(i, j), B(i, j) 表示从点 i 长度为 j 的两种路径是否存在. 用bitset就行了 时间复杂度O(m) ---------------------------------------------------------------- #include<bits/stdc++.h>   #define clr(x, c) memset(x, c, sizeof(x)) #define rep(i, n) for(int i = 0; i < n;…
[USACO15JAN]电影移动Moovie Mooving 时间限制: 2 Sec  内存限制: 128 MB 题目描述 Bessie is out at the movies. Being mischievous as always, she has decided to hide from Farmer John for L (1 <= L <= 100,000,000) minutes, during which time she wants to watch movies conti…
[Usaco2015 Jan]Grass Cownoisseur 题目 给一个有向图,然后选一条路径起点终点都为1的路径出来,有一次机会可以沿某条边逆方向走,问最多有多少个点可以被经过? (一个点在路径中无论出现多少正整数次对答案的贡献均为1) INPUT The first line of input contains N and M, giving the number of fields and the number of one-way paths (1 <= N, M <= 100,…
BZOJ3887 [Usaco2015 Jan] Grass Cownoisseur Description In an effort to better manage the grazing patterns of his cows, Farmer John has installed one-way cow paths all over his farm. The farm consists of N fields, conveniently numbered 1..N, with each…
题意: 给一个有向图,然后选一条路径起点终点都为1的路径出来,有一次机会可以沿某条边逆方向走,问最多有多少个点可以被经过?(一个点在路径中无论出现多少正整数次对答案的贡献均为1) =>有向图我们先考虑缩点.然后观察缩点后的图可以发现新的路径中必定只有一条边是反向的才符合条件.那么我们可以联想到某道最短路的题将边反向存一遍后分别从s和t跑一跑.那么这里bfs跑一跑就行了.然后有一个坑点:这种重建图的注意es和edges不然es会在中途就被修改掉了... #include<cstdio> #…
BZOJ_3887_[Usaco2015 Jan]Grass Cownoisseur_强连通分量+拓扑排序+DP Description In an effort to better manage the grazing patterns of his cows, Farmer John has installed one-way cow paths all over his farm. The farm consists of N fields, conveniently numbered 1…
[Usaco2015 Jan]Grass Cownoisseur 题目大意:给一个有向图,然后选一条路径起点终点都为1的路径出来,有一次机会可以沿某条边逆方向走,问最多有多少个点可以被经过?(一个点在路径中无论出现多少正整数次对答案的贡献均为1) 数据范围:$1\le n, m\le 10^5$. 题解: 先$tarjan$缩强连通分量,因为每一个$SCC$只要能到一个点就能到整个$SCC$. 接下来我们发现,我们操作的边的两个端点会满足如下性质: 这条有向边的起点可以到$1$号点所在$SCC$…