P2853 [USACO06DEC]牛的野餐Cow Picnic

你愿意的话,可以写dj。

然鹅,对一个缺时间的退役选手来说,暴力模拟是一个不错的选择。

让每个奶牛都把图走一遍,显然那些被每个奶牛都走过的点就是符合条件的点。

 #include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 1002
int val[N],in[N],k,n,m,ans;
bool d[N][N],vis[N];
void dfs(int x,int t){
vis[x]=; val[x]+=t;
for(int i=;i<=n;++i)
if(d[x][i]&&!vis[i])
dfs(i,t);
}
int main(){
scanf("%d%d%d",&k,&n,&m);
for(int q,i=;i<=k;++i)
scanf("%d",&q),++in[q];
for(int i=,q1,q2;i<=m;++i)
scanf("%d%d",&q1,&q2),d[q1][q2]=;
for(int i=;i<=n;++i)
if(in[i]){
memset(vis,,sizeof(vis));
dfs(i,in[i]);
}
for(int i=;i<=n;++i)
if(val[i]==k) ++ans;
printf("%d",ans);
return ;
}

bzoj1648 / P2853 [USACO06DEC]牛的野餐Cow Picnic的更多相关文章

  1. 洛谷——P2853 [USACO06DEC]牛的野餐Cow Picnic

    P2853 [USACO06DEC]牛的野餐Cow Picnic 题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ ...

  2. 洛谷 P2853 [USACO06DEC]牛的野餐Cow Picnic

    P2853 [USACO06DEC]牛的野餐Cow Picnic 题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ ...

  3. 洛谷P2853 [USACO06DEC]牛的野餐Cow Picnic

    题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ 100) cows is grazing in one of N ...

  4. P2853 [USACO06DEC]牛的野餐Cow Picnic

    ------------------------- 长时间不写代码了,从学校中抽身出来真的不容易啊 ------------------------ 链接:Miku ----------------- ...

  5. 题解【洛谷P2853】[USACO06DEC]牛的野餐Cow Picnic

    题目描述 The cows are having a picnic! Each of Farmer John's \(K (1 ≤ K ≤ 100)\) cows is grazing in one ...

  6. [USACO06DEC]牛的野餐Cow Picnic DFS

    题目描述 The cows are having a picnic! Each of Farmer John's K (1 ≤ K ≤ 100) cows is grazing in one of N ...

  7. 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐

    1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 432  Solved: 270[ ...

  8. Bzoj 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 深搜,bitset

    1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐 Time Limit: 5 Sec  Memory Limit: 64 MBSubmit: 554  Solved: 346[ ...

  9. BZOJ 1648: [Usaco2006 Dec]Cow Picnic 奶牛野餐( dfs )

    直接从每个奶牛所在的farm dfs , 然后算一下.. ----------------------------------------------------------------------- ...

随机推荐

  1. 存储opline的内存地址可以实时跟踪opcode的执行

    static intphp_handler(request_rec *r) { /* Initiliaze the context */ php_struct * volatile ctx; void ...

  2. Linux查看及设置系统字符集

    查看正在使用的字符集 查看可以设置的字符集 locale -a 修改字符集 export LANG=zh_CN.gbk

  3. HOJ 2133&POJ 2964 Tourist(动态规划)

    Tourist Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 1503 Accepted: 617 Description A ...

  4. poj2752seek the name, seek the fame【kmp】

    The little cat is so famous, that many couples tramp over hill and dale to Byteland, and asked the l ...

  5. 2018-2019-2 20165330《网络对抗技术》Exp3 免杀原理与实践

    目录 基础问题 相关知识 实验内容 实验步骤 实验过程中遇到的问题 离实战还缺些什么技术或步骤? 实验总结与体会 实验内容 正确使用msf编码器,msfvenom生成如jar之类的其他文件,veil- ...

  6. JSTL 学习

    对于页面访问数据的统计,可以使用内置对象的相应方法进行计数工作,这个对象要在jsp对象的整个生命周期中setAttribute()和getAttribute()application.setAttri ...

  7. postgresql shell发起select操作报错ERROR: relation "tablename" does not exist

    最近安装了一套clourdera manager,其中hive元数据保存在postgresql中,因为今天想看一下hive的元数据信息,就登录了psql,连接到hive元数据库,发起select操作, ...

  8. laravel5.1接收ajax数据

    前台: $.ajax({ type: 'POST', url: '{!! url('aw/data') !!}', data:{'_token':'<?php echo csrf_token() ...

  9. 解决UITableView分割线距左边有距离的办法

    首先在viewDidLoad方法中加上如下代码: if ([self.tableView respondsToSelector:@selector(setSeparatorInset:)]) {    ...

  10. C语言概述

    打印摄氏度 /* 1.1 使用int类型进行计算 */ #include <stdio.h> /* print Fahrenheit-Celsius table for fahr = 0, ...