"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. [软件工程基础]2017.11.04 第八次 Scrum 会议

    具体事项 项目交接燃尽图 每人工作内容 成员 已完成的工作 计划完成的工作 工作中遇到的困难 游心 #10 搭建可用的开发测试环境:#9 阅读分析 PhyLab 后端代码与文档:#8 掌握 Larav ...

  2. bzoj 4695: 最假女选手 && Gorgeous Sequence HDU - 5306 && (bzoj5312 冒险 || 小B的序列) && bzoj4355: Play with sequence

    算导: 核算法 给每种操作一个摊还代价(是手工定义的),给数据结构中某些东西一个“信用”值(不是手动定义的,是被动产生的),摊还代价等于实际代价+信用变化量. 当实际代价小于摊还代价时,增加等于差额的 ...

  3. centOS 部署服务器(三)

    今天一个新的项目终于能够重新安装mysql了,分享下步骤: 1.下载地址:http://dev.mysql.com/downloads/mysql/  (选择Linux - Generic版本的Lin ...

  4. Jmeter(二十三)稳定性测试后的波形图

    jmeter-plugins.org 这个网站为 JMeter 提供了一些增强型功能的插件,使用起来就像 Eclipse 装插件一样,完全做到了插件的可插拔特性.本文简要介绍如何使用这些插件让你的 J ...

  5. 04.Javascript——入门一些方法记录之iterable

    遍历Array可以采用下标循环,遍历Map和Set就无法使用下标.为了统一集合类型,ES6标准引入了新的iterable类型,Array.Map和Set都属于iterable类型. 具有iterabl ...

  6. Chess 模拟

    链接:http://acm.hdu.edu.cn/showproblem.php?pid=6114 Problem Description 車是中国象棋中的一种棋子,它能攻击同一行或同一列中没有其他棋 ...

  7. 从Assets读取文件 用scanner扫描inputstream

    代码如下: 对InputStream的处理,从assets获取数据 InputStream in; try { in = getAssets().open("Android05.txt&qu ...

  8. Gitlab User Guide

    Installation Configuration Set user name and email Add SSH keys Repository Create New Repository Clo ...

  9. Spring下读取properties文件

    由于在spring的xml文件中配置了 <bean id="validator" class="org.springframework.validation.bea ...

  10. 用YII实现多重查询(基于tag)

    场景: 有一个饭店表 restaurant,存放所有饭店记录.我需要一个功能,将饭店按照不同的条件进行多重查询.就象这样:   氛围:浪漫 / 商务会谈 / 茅草屋 菜系:川菜 / 鲁菜 / 家常菜. ...