Problem Statement

You are given a simple undirected graph with $N$ vertices and $M$ edges. The vertices are numbered $1, \dots, N$, and the $i$-th $(1 \leq i \leq M)$ edge connects Vertices $U_i$ and $V_i$.

There are $2^N$ ways to paint each vertex red or blue. Find the number, modulo $998244353$, of such ways that satisfy all of the following conditions:

  • There are exactly $K$ vertices painted red.
  • There is an even number of edges connecting vertices painted in different colors.

Constraints

  • $2 \leq N \leq 2 \times 10^5$
  • $1 \leq M \leq 2 \times 10^5$
  • $0 \leq K \leq N$
  • $1 \leq U_i \lt V_i \leq N \, (1 \leq i \leq M)$
  • $(U_i, V_i) \neq (U_j, V_j) \, (i \neq j)$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$ $M$ $K$
$U_1$ $V_1$
$\vdots$
$U_M$ $V_M$

Output

Print the answer.


Sample Input 1

4 4 2
1 2
1 3
2 3
3 4

选出来的 $k$ 个红色点点的度数之和一定是偶数。如果一条边链接两个红色点,那么他会被算两次。如果他链接一个红色点和一个蓝色点,那么按要求,这种边有奇数个。
换句话说,我们只能选择偶数个奇数度数的店。枚举选 $i$ 个奇数度数的点,设有 $c0$ 个偶数度数的点,$c1$ 个奇数度数的店,那么答案加上 $C_{c0}^{k-i}\times C_{c1}^i$

#include<cstdio>
const int N=2e5+5,P=998244353;
int n,m,k,in[N],jc[N],c1,c0,u,v,ans;
int pow(int x,int y)
{
if(!y)
return 1;
int t=pow(x,y>>1);
if(y&1)
return 1LL*t*t%P*x%P;
return 1LL*t*t%P;
// return (y&1)? 1LL*t*t%P*x%P:1LL*t*t%P;
}
int calc(int x,int y)
{
if(x<y)
return 0;
return 1LL*jc[x]*pow(jc[y],P-2)%P*pow(jc[x-y],P-2)%P;
}
int main()
{
scanf("%d%d%d",&n,&m,&k);
for(int i=jc[0]=1;i<=n;i++)
jc[i]=1LL*jc[i-1]*i%P;
// printf("%d\n",pow(2,10)%P);
for(int i=1;i<=m;i++)
{
scanf("%d%d",&u,&v);
in[u]++,in[v]++;
}
for(int i=1;i<=n;i++)
in[i]&1? c1++:c0++;
// printf("%d %d\n",c1,c0);
for(int i=0;i<=k;i+=2)//选多少个奇数的
{
// printf("%d %d %d\n",i,calc(c1,i),calc(c0,k-i));
ans+=1LL*calc(c1,i)*calc(c0,k-i)%P;
ans%=P;
}
printf("%d",ans);
}

[ABC262E] Red and Blue Graph的更多相关文章

  1. AC日记——Red and Blue Balls codeforces 399b

    399B - Red and Blue Balls 思路: 惊讶的发现,所有的蓝球的消除都是独立的: 对于在栈中深度为i的蓝球消除需要2^i次操作: 代码: #include <cstdio&g ...

  2. codeforces 399B. Red and Blue Balls 解题报告

    题目链接:http://codeforces.com/problemset/problem/399/B 题目意思:给出 n 个只由 R 和 B 组成的字符串(由上到下排列,相当于栈),问最多可以操作多 ...

  3. Codeforces Round #233 (Div. 2) B. Red and Blue Balls

    #include <iostream> #include <string> using namespace std; int main(){ int n; cin >&g ...

  4. cf B Red and Blue Balls

    思路:把字符串转化为一个二进制,遇到B就是一个数二进制中的1,答案就是这个数. #include <cstdio> #include <cstring> #include &l ...

  5. 洛谷 CF399B【Red and Blue Balls】题解

    n年没有更博客:我总结出了规律,当学的东西很难得时候都去学习,没有时间写博客,只有 内容对于我这种蒟蒻友好,又让我非常闲的慌时才写博客,这种博客以后也没有价值(也有些是做完一道题有成就感写的) 最近内 ...

  6. CF399B Red and Blue Balls

    题目 CF399B 洛谷RemoteJudge 思路 很容易发现,栈中靠上的蓝色球的出栈,对它下方的蓝色球没有影响. 举个例子: 第一步中靠上的蓝色球在第三步出栈了,这一过程对它下面的蓝色球(即第一步 ...

  7. [Swift]LeetCode785. 判断二分图 | Is Graph Bipartite?

    Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipart ...

  8. Is Graph Bipartite?

    Given an undirected graph, return true if and only if it is bipartite. Recall that a graph is bipart ...

  9. Unity 最佳实践

    转帖:http://www.glenstevens.ca/unity3d-best-practices/ 另外可以参考:http://devmag.org.za/2012/07/12/50-tips- ...

  10. (转) Graph-powered Machine Learning at Google

        Graph-powered Machine Learning at Google     Thursday, October 06, 2016 Posted by Sujith Ravi, S ...

随机推荐

  1. github.com/yuin/gopher-lua 踩坑日记

    本文主要记录下在日常开发过程中, 使用 github.com/yuin/gopher-lua 过程中需要注意的地方. 后续遇到其他的需要注意的事项再补充. 1.加载LUA_PATH环境变量 在实际开发 ...

  2. redhat7 team bonding 双网卡绑定 主备 负载均衡

    team简介 team也被称为网络组,是将多个网卡聚合在一起,从而实现冗错和提高吞吐量.适用于redhat7.0以上版本,至多可支持8块网卡.team相对于之前的bonding技术,能提供更好的性能和 ...

  3. Haproxy搭建 Web 群集实现负载均衡

    Haproxy搭建 Web 群集实现负载均衡 1 Haproxy HAProxy是可提供高可用性.负载均衡以及基于TCP和HTTP应用的代理,是免费.快速并且可靠的一种解决方案.HAProxy非常适用 ...

  4. SQL函数count(),sum()理解

    ①准备-创建测试表: create table test ( id SMALLINT, name varchar(10) ); 插入数据: insert into test values(0,'张三' ...

  5. tiptopGP5.2链接所有表或报不存在函数处理

    修改交易的表时需要特别注意,改完要关联所有有关的表r.rb.rb pja_file 当链接提示不存在的函数调用,又无法确定具体是那个关联程序时, 可以在本函数内先定义这个报错的函数,重新链接时,系统会 ...

  6. 创建Oracle数据库实例、配置PLSQL连接数据库实例

    方法一:仅安装Oracle即时客户端: 1.安装Oracle即时客户端Instant Client Setup.exe,配置环境变量 2.安装PLSQL工具,配置Oracle主目录名和OCI库 3.配 ...

  7. hash code

    值相同却可能有不同的hashcode //对象值到底指什么?(x.equals(y) == true)应该并不代表对象值相同 class A { A(){} public boolean equals ...

  8. Jmeter将响应数据的结果保存到本地的一个文件(xls和csv)

    打印excel和csv文件的区别?? 第一种:打印excel 第二种:打印csv文件 创建beanshell后置处理器  import org.json.*;import java.io.*; Str ...

  9. 多源异构数据信息的融合方式0 - Dempster/Shafer 证据理论(D-S证据理论)

    Dempster/Shafer 证据理论(D-S证据理论)的大体内容如下: 一.简介: 在理论中,由互不相容的基本命题组成的完备集合Θ称为识别框架,表示对于某一问题的所有可能答案,但是只有一个答案是正 ...

  10. docker入门加实战—docker常见命令

    docker入门加实战-docker常见命令 在介绍命令之前,先用一副图形象的展示一下docker的命令: 常见命令 docker的常见命令和文档地址如下表: 命令 说明 文档地址 docker pu ...