BZOJ 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐( dfs )
直接从每个奶牛所在的farm dfs , 然后算一下..
----------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------
1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐
Time Limit: 5 Sec Memory Limit: 64 MB
Submit: 456 Solved: 283
[Submit][Status][Discuss]
Description
The cows are having a picnic! Each of Farmer John's K (1 <= K <= 100) cows is grazing in one of N (1 <= N <= 1,000) pastures, conveniently numbered 1...N. The pastures are connected by M (1 <= M <= 10,000) one-way paths (no path connects a pasture to itself). The cows want to gather in the same pasture for their picnic, but (because of the one-way paths) some cows may only be able to get to some pastures. Help the cows out by figuring out how many pastures are reachable by all cows, and hence are possible picnic locations.
Input
* Line 1: Three space-separated integers, respectively: K, N, and M * Lines 2..K+1: Line i+1 contains a single integer (1..N) which is the number of the pasture in which cow i is grazing. * Lines K+2..M+K+1: Each line contains two space-separated integers, respectively A and B (both 1..N and A != B), representing a one-way path from pasture A to pasture B.
第1行输入K,N,M.接下来K行,每行一个整数表示一只奶牛所在的牧场编号.接下来M行,每行两个整数,表示一条有向路的起点和终点
Output
* Line 1: The single integer that is the number of pastures that are reachable by all cows via the one-way paths.
所有奶牛都可到达的牧场个数
Sample Input
2
3
1 2
1 4
2 3
3 4
INPUT DETAILS:
4<--3
^ ^
| |
| |
1-->2
The pastures are laid out as shown above, with cows in pastures 2 and 3.
Sample Output
牧场3,4是这样的牧场.
HINT
Source
BZOJ 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐( dfs )的更多相关文章
- Bzoj 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 深搜,bitset
1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 554 Solved: 346[ ...
- BZOJ 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐
Description The cows are having a picnic! Each of Farmer John's K (1 <= K <= 100) cows is graz ...
- bzoj 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐【dfs】
从每个奶牛所在草场dfs,把沿途dfs到的草场的con都+1,最后符合条件的草场就是con==k的,扫一遍统计一下即可 #include<iostream> #include<cst ...
- 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐
1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 432 Solved: 270[ ...
- 【BZOJ】1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐(dfs)
http://www.lydsy.com/JudgeOnline/problem.php?id=1648 水题.. dfs记录能到达的就行了.. #include <cstdio> #in ...
- bzoj1648 [Usaco2006 Dec]Cow Picnic 奶牛野餐
Description The cows are having a picnic! Each of Farmer John's K (1 <= K <= 100) cows is graz ...
- BZOJ 1649: [Usaco2006 Dec]Cow Roller Coaster( dp )
有点类似背包 , 就是那样子搞... --------------------------------------------------------------------------------- ...
- BZOJ——1649: [Usaco2006 Dec]Cow Roller Coaster
http://www.lydsy.com/JudgeOnline/problem.php?id=1649 Time Limit: 5 Sec Memory Limit: 64 MBSubmit: 7 ...
- bzoj 1649: [Usaco2006 Dec]Cow Roller Coaster【dp】
DAG上的dp 因为本身升序就是拓扑序,所以建出图来直接从1到ndp即可,设f[i][j]为到i花费了j #include<iostream> #include<cstdio> ...
随机推荐
- Spring Annotation vs XML - 示例
来源: http://hanqunfeng.iteye.com/blog/2113820 作者hanqunfeng的示例文件: (可下载) web-mvc.zip
- Spring--依赖注入
Spring 能有效地组织J2EE应用各层的对象.不管是控 制层的Action对象,还是业务层的Service对象,还是持久层的DAO对象,都可在Spring的 管理下有机地协调.运行.Spring将 ...
- Grunt.js 上手
Official Site gruntjs.org/docs/getting-started.html 或者看http://tgideas.qq.com/webplat/info/news_versi ...
- jQuery json数据处理
一种是使用jQuery的ajax函数 另一种是使用getJSON函数 使用ajax函数的时候 对于返回值类型dataType 亲自指定为json格式 就无需自己手动处理格式 $.ajax({ url ...
- perl lwp 超时问题
lwp 超时问题: jrhmpt01:/root/async# cat a1.pl use LWP::UserAgent; use utf8; use DBI; use POSIX; use Data ...
- python使用easygui写图形界面程序
我 们首先下载一个类库easygui,它是一个Python用于简单开发图形化界面的类库,打开easygui的下载网页 http://sourceforge.net/projects/easygui/? ...
- nodejs--express开发博客系统(三)
上一节已经实现了登录.注册.发表文章和文章读取的功能,今天咱加上评论.文章页面和作者页面. 评论只能在进入文章页面后才能进行,所以咱们先写文章页面. 在上一节的代码中,我已经给文章标题添加了超链接了, ...
- 在 Linux RedHatEL6 环境下安装配置 JDK1.7 + Tomcat7.0 + MySQL5.6
RedHatEL6 JDK安装路径: /usr/java/jdk1.7 Tomcat安装路径:/usr/local/tomcat7/ MySQL安装路径: /usr/local/mysql 总共分为以 ...
- c 判断水仙花数,质数(素数)
#include<stdio.h> #include<stdbool.h> //水仙花数--各位立方和等于本身 void sXh() { int x,y,z; printf(& ...
- PeopleEditor的取值及赋值
/// <summary> /// 从PeopleEditor取值 /// </summary> /// <param name="peopleEditor&q ...