Promotions Gym
来源:互联网 发布:java onvif 编辑:程序博客网 时间:2024/05/17 13:39
#include<cstdio>#include<cstring>#include<cmath>#include<cstdlib>#include<vector>using namespace std;vector<int> mm[5005];vector<int> nn[5005];int a,b,e,p;int vis[5100];int num[5100];void dfs1(int pos){ num[pos] ++; int len = mm[pos].size(); for(int i = 0; i < len; i ++) { if( vis[ mm[pos][i] ] ) continue; vis[ mm[pos][i] ] = 1; dfs1( mm[pos][i] ); }}void dfs2(int pos){ num[pos] ++; int len = nn[pos].size(); for(int i = 0; i < len; i ++) { if( vis[ nn[pos][i]] ) continue; vis[ nn[pos][i] ] = 1; dfs2( nn[pos][i] ); }}int main(){ scanf("%d%d%d%d",&a,&b,&e,&p); for(int i = 0; i < p; i ++) { int aa,bb; scanf("%d%d",&aa,&bb); mm[bb].push_back(aa); nn[aa].push_back(bb); } memset(vis,0,sizeof(vis)); memset(num,0,sizeof(num)); for(int i = 0; i < e; i ++) { memset(vis,0,sizeof(vis)); dfs1(i); } int res1 = 0,res2 = 0; for(int i = 0; i < e; i ++) { if( e - num[i] < a) res1 ++; if( e - num[i] < b) res2 ++; } memset(vis,0,sizeof(vis)); memset(num,0,sizeof(num)); for(int i = 0; i < e; i ++) { memset(vis,0,sizeof(vis)); dfs2(i); } int res3 = 0; for(int i = 0; i < e; i ++) if( num[i] > b) res3 ++; printf("%d\n%d\n%d\n",res1,res2,res3); return 0;}
两次搜索,一次搜后面有多少人,一次搜前面有多少人
0 0
- Promotions Gym
- Promotions Gym
- GYM 101128 A.Promotions(dfs)
- GYM 101128 A.Promotions(dfs)
- GYM 101128 A.Promotions【思维+暴力】
- A - Promotions
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- Gym
- [C++]union联合体总结
- K-means 之国足小例子
- 剑指offer第二题
- iOS学习笔记-069.手势识别03——抽屉控件实现
- web安全与防御---3.kali环境下sqlmap的注入
- Promotions Gym
- MSSql dbcc checkdb 出现错误处理
- 快速上手Ubuntu之安装常用软件篇——打造一个满足基本娱乐办公的Ubuntu
- iOS scene之间的跳转类型——Segue
- 运维小技巧:使用ss命令代替 netstat,和netstat说再见
- C/C++使用Select检索MySQL中的数据
- 分布式事务中2PC与3PC的区别
- 常见的异常
- PAT 乙级1002