ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph
"Oh, There is a bipartite graph.""Make it Fantastic."
X wants to check whether a bipartite graph is a fantastic graph. He has two fantastic numbers, and he wants to let all the degrees to between the two boundaries. You can pick up several edges from the current graph and try to make the degrees of every point to between the two boundaries. If you pick one edge, the degrees of two end points will both increase by one. Can you help X to check whether it is possible to fix the graph?
Input
There are at most 3030 test cases.
For each test case,The first line contains three integers NN the number of left part graph vertices, MM the number of right part graph vertices, and KK the number of edges ( 1 \le N \le 20001≤N≤2000,0 \le M \le 20000≤M≤2000,0 \le K \le 60000≤K≤6000 ). Vertices are numbered from 11 to NN.
The second line contains two numbers L, RL,R (0 \le L \le R \le 300)(0≤L≤R≤300). The two fantastic numbers.
Then KK lines follows, each line containing two numbers UU, VV (1 \le U \le N,1 \le V \le M)(1≤U≤N,1≤V≤M). It shows that there is a directed edge from UU-th spot to VV-th spot.
Note. There may be multiple edges between two vertices.
Output
One line containing a sentence. Begin with the case number. If it is possible to pick some edges to make the graph fantastic, output "Yes" (without quote), else output "No" (without quote).
样例输入复制
3 3 7
2 3
1 2
2 3
1 3
3 2
3 3
2 1
2 1
3 3 7
3 4
1 2
2 3
1 3
3 2
3 3
2 1
2 1
样例输出复制
Case 1: Yes
Case 2: No
题目来源
一个二分图,M条边,选用M条边的一些,令最后所有点的度数都在[l,r]内 ,可以Yes 否则 No
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
using namespace std;
#define P pair<int,int>
#define ph push_back
#define ll long long
#define M 4400
#define fi first
#define se second
vector<P>ve[M];
int num[M],e[M];
int n,m,k,l,r;
void dfs(int sta,int maxx)
{
for(int i=;i<ve[sta].size();i++){
P p=ve[sta][i];
if(!e[p.se]){
e[p.se]=;
if(num[p.fi]<maxx&&num[sta]<maxx){//遍历所有的边,在maxx的范围内,尽量用边
num[p.fi]++;
num[sta]++;
dfs(p.fi,maxx);
}
}
}
}
void init()
{
for(int i=;i<=n+m;i++)
{
num[i]=;
e[i]=;
ve[i].clear();
}
}
int main()
{
int cnt=;
while(~scanf("%d%d%d",&n,&m,&k)){
init();
scanf("%d%d",&l,&r);
int x,y;
for(int i=;i<k;i++)
{
scanf("%d%d",&x,&y);
ve[x].ph({y+n,i});
ve[y+n].ph({x,i});
}
dfs(,r);
int flag=;
for(int i=;i<=n+m;i++)
{
if(num[i]<l) {//如果最后还有点的度数不满足条件,就No
flag=;
break;
}
}
printf("Case %d: ",++cnt);
printf("%s\n",flag?"Yes":"No");
}
return ;
}
ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph的更多相关文章
- ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph (上下界网络流)
正解: #include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN=1 ...
- ACM-ICPC 2018 沈阳赛区网络预赛 F Fantastic Graph(贪心或有源汇上下界网络流)
https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. ...
- ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph (贪心或有源汇上下界网络流)
"Oh, There is a bipartite graph.""Make it Fantastic."X wants to check whether a ...
- ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph(有源上下界最大流 模板)
关于有源上下界最大流: https://blog.csdn.net/regina8023/article/details/45815023 #include<cstdio> #includ ...
- Fantastic Graph 2018 沈阳赛区网络预赛 F题
题意: 二分图 有k条边,我们去选择其中的几条 每选中一条那么此条边的u 和 v的度数就+1,最后使得所有点的度数都在[l, r]这个区间内 , 这就相当于 边流入1,流出1,最后使流量平衡 解析: ...
- ACM-ICPC 2018 沈阳赛区网络预赛-D:Made In Heaven(K短路+A*模板)
Made In Heaven One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. ...
- 图上两点之间的第k最短路径的长度 ACM-ICPC 2018 沈阳赛区网络预赛 D. Made In Heaven
131072K One day in the jail, F·F invites Jolyne Kujo (JOJO in brief) to play tennis with her. Howe ...
- ACM-ICPC 2018 沈阳赛区网络预赛 K Supreme Number(规律)
https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集 ...
- ACM-ICPC 2018 沈阳赛区网络预赛-K:Supreme Number
Supreme Number A prime number (or a prime) is a natural number greater than 11 that cannot be formed ...
随机推荐
- Vue初始化
Vue上面的函数怎么来的 vue的打包路径 在web中使用的vue打包路径: npm run build 打包生成vue.js 下面是依次引入: src/platforms/web/entry-run ...
- Azure service bus Topic基本用法
我们在升级一个POS系统的时候,决定使用微软公有云计算平台下的Azure ServiceBus 进行POS客户端与服务器的交互. 本文主要时作者在学习使用 Azure SDK for .NET 操作由 ...
- python语法:
1 #开始注释,‘’‘ ‘’’可以看做是文本字符串也可以看做是块注释:”:“开始后的缩进视为一个代码块类似{}:缩进没有规定,但一般4个空格,注意:粘贴复制代码一定要检查缩进:大小写敏感: 2 数据 ...
- C#打开office文件,pdf文件和视频文件
打开office文件 1 需要从网站下载dsoframer.ocx文件 2 把dsoframer.ocx文件复制到c:\windows\system32目录下 开始->运行->regsvr ...
- 【extjs6学习笔记】0.2 准备:类库结构
- 【读书笔记】构建之法(CH1~CH3)
人类文明的发展离不开哲学家的思考.科学家的发现和工程师的构建.三个简单的方程式解释了什么是现代软件工程: 1.程序=算法+数据结构 2.软件=程序+软件工程 3.软件企业=软件+商业模式 软件开发的不 ...
- (转)ASIC设计中各个阶段需要注意的问题——节选
ASIC 的复杂性不断提高,同时工艺在不断地改进,如何在较短的时间内开发一个稳定的可重用的ASIC芯片的设计,并且一次性流片成功,这需要一个成熟的ASIC 的设计方法和开发流程.本文结合NCveril ...
- C# 语句 分支语句
语句是指程序命令,按照顺序执行.可以分为 顺序语句 分支语句 循环语句 之前学习的内容都是按照顺序程序执行的,称之为顺序语句. 今天学的的内容是分支语句. 语句可以嵌套,可以是以分号结尾的单行 ...
- xcode或者mac自带颜色器选择rgb格式
解决方法
- win10 多桌面 win+tab | ctrl+win+左右箭头
win10 多桌面 win+tab | ctrl+win+左右箭头