"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

题目来源

ACM-ICPC 2018 沈阳赛区网络预赛

一个二分图,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的更多相关文章

  1. ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph (上下界网络流)

    正解: #include <bits/stdc++.h> using namespace std; const int INF = 0x3f3f3f3f; const int MAXN=1 ...

  2. ACM-ICPC 2018 沈阳赛区网络预赛 F Fantastic Graph(贪心或有源汇上下界网络流)

    https://nanti.jisuanke.com/t/31447 题意 一个二分图,左边N个点,右边M个点,中间K条边,问你是否可以删掉边使得所有点的度数在[L,R]之间 分析 最大流不太会.. ...

  3. ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph (贪心或有源汇上下界网络流)

    "Oh, There is a bipartite graph.""Make it Fantastic."X wants to check whether a ...

  4. ACM-ICPC 2018 沈阳赛区网络预赛 F. Fantastic Graph(有源上下界最大流 模板)

    关于有源上下界最大流: https://blog.csdn.net/regina8023/article/details/45815023 #include<cstdio> #includ ...

  5. Fantastic Graph 2018 沈阳赛区网络预赛 F题

    题意: 二分图 有k条边,我们去选择其中的几条 每选中一条那么此条边的u 和 v的度数就+1,最后使得所有点的度数都在[l, r]这个区间内 , 这就相当于 边流入1,流出1,最后使流量平衡 解析: ...

  6. 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. ...

  7. 图上两点之间的第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 ...

  8. ACM-ICPC 2018 沈阳赛区网络预赛 K Supreme Number(规律)

    https://nanti.jisuanke.com/t/31452 题意 给出一个n (2 ≤ N ≤ 10100 ),找到最接近且小于n的一个数,这个数需要满足每位上的数字构成的集合的每个非空子集 ...

  9. 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 ...

随机推荐

  1. POJ-3275:Ranking the Cows(Floyd、bitset)

    Ranking the Cows Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 3301   Accepted: 1511 ...

  2. MODBUS移植的参考文章

    https://github.com/armink/FreeModbus_Slave-Master-RTT-STM32 http://www.360doc.com/content/14/0906/09 ...

  3. qq登录,新浪微博登录接口申请过程中遇到的问题

    接口申请下来了,开发很容易的,参数传到就可以了.以前就做过这方面的开发,但是申请还是第一次,网上有关这方面的东东不是很多,所以记录一下申请过程. 1,qq登录接口申请 申请地址是:http://con ...

  4. Nginx 开启目录浏览功能配置

    在server节点下添加 server { listen ; server_name default; #index index.php; # 目录浏览功能 autoindex on; # 显示文件大 ...

  5. Linux 环境下安装 Nginx+php+mysql 开发环境

    一直以来都没有养成记录学习的好习惯,我想从这么一天开始,把自己学习和工作中的经验和坑都记录下来.等到以后老的时候还有可以回忆的地方. 最近在学习linux,虽然已经玩linux很久了,但是没有怎么用心 ...

  6. window server 2012R2服务器部署遇到的问题

    1. 出现问题原因:服务器的Framework4.5 未安装, 解决办法:从网上下载之后,安装,然后重启服务器即可 2. 出现问题原因:内存不足或者虚拟内存不足 解决办法:设置虚拟内存来解决,步骤如下 ...

  7. react中的context的基础用法

    context提供了一种数据共享的机制,里面有两个关键概念——provider,consumer,下面做一些key features描述. 参考网址:https://react.docschina.o ...

  8. JS基础1 — 代码要注意的一些问题

    1.在一对  <script></script>  标签中,有错的js代码,那么该错误代码后面的代码不会执行. 例子:<script> alert("He ...

  9. PL/SQL学习笔记(四)之——删除重复记录

    例:假设员工表中有若干记录重复,请删除重复的记录(某企业面试题) ------模拟建表 create table employee( e_id varchar2(20) primary key, e_ ...

  10. OpenStack安装keyston 错误BError: (pymysql.err.InternalError) (1071, u‘Specified key was too long; max key length is 767 bytes‘) [SQL: u‘\nCREATE TABLE migrate_ver

    折腾了两天的错误,BError: (pymysql.err.InternalError) (1071, u‘Specified key was too long; max key length is ...