zoukankan      html  css  js  c++  java
  • 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 20001N2000,0 le M le 20000M2000,0 le K le 60000K6000 ). Vertices are numbered from 11 to NN.

    The second line contains two numbers L, RL,(0 le L le R le 300)(0LR300). The two fantastic numbers.

    Then KK lines follows, each line containing two numbers UU, V(1 le U le N,1 le V le M)(1UN,1VM). 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

     

     

     1 #include <iostream>
     2 #include <vector>
     3 #include <cstdio>
     4 #include <cstring>
     5 using  namespace  std;
     6 #define  P pair<int,int>
     7 #define  ph  push_back
     8 #define  ll long long 
     9 #define  M 4400
    10 #define  fi  first
    11 #define  se second
    12 vector<P>ve[M];
    13 int num[M],e[M];
    14 int n,m,k,l,r;
    15 void dfs(int sta,int maxx)
    16 {
    17     for(int i=0;i<ve[sta].size();i++){
    18         P  p=ve[sta][i];
    19         if(!e[p.se]){
    20             e[p.se]=1;
    21             if(num[p.fi]<maxx&&num[sta]<maxx){//遍历所有的边,在maxx的范围内,尽量用边
    22                 num[p.fi]++;
    23                 num[sta]++;
    24                 dfs(p.fi,maxx);
    25             }
    26         }
    27     }
    28 }
    29 void  init()
    30 {
    31     for(int i=1;i<=n+m;i++)
    32         {
    33             num[i]=0;
    34             e[i]=0;
    35             ve[i].clear();
    36         }
    37 }
    38 int main()
    39 {
    40     int cnt=0;
    41     while(~scanf("%d%d%d",&n,&m,&k)){
    42         init();
    43         scanf("%d%d",&l,&r);        
    44         int x,y;
    45         for(int i=0;i<k;i++)
    46         {
    47             scanf("%d%d",&x,&y);
    48             ve[x].ph({y+n,i});
    49             ve[y+n].ph({x,i});
    50         }
    51         dfs(1,r);
    52         int flag=1;
    53         for(int i=1;i<=n+m;i++)
    54         {
    55             if(num[i]<l) {//如果最后还有点的度数不满足条件,就No
    56                 flag=0;
    57                 break;
    58             }
    59         }
    60         printf("Case %d: ",++cnt);
    61         printf("%s
    ",flag?"Yes":"No");
    62     }
    63     return 0;
    64 }
  • 相关阅读:
    使用日历控件的一些体会(downmoon)
    带附加条件的NewID()用法
    微软的招聘哲学——做微软人的五大核心素质(摘自《微软360度》)
    彻底禁用fckEditor的上传功能(含防止Type漏洞问题)
    Remote Access Connection Manager 服务因下列错误而停止解决办法
    GridView如何更新批量数据和单条记录?
    .net1.1与.net2.0在加载ascx文件的控件时有所不同(Downmoon)
    牛羊吃草问题求解(downmoon)
    c#操作ecxel的一些资源(downmoon搜集)
    安装sql2008 enterprise (English正式版)图解
  • 原文地址:https://www.cnblogs.com/tingtin/p/9610097.html
Copyright © 2011-2022 走看看