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. 按关键字API接口搜索天眼查企业数据

    一.如果你想要查找某一个企业的基本信息或是对行业中的企业进行筛选,那么使用API接口搜索天眼查企业数据会非常方便. 首先,你需要获取天眼查API的access_token,这可以通过注册账号获取.一旦 ...

  2. C#/.NET/.NET Core优秀项目和框架8月简报

    前言 公众号每月定期推广和分享的C#/.NET/.NET Core优秀项目和框架(公众号每周至少推荐两个优秀的项目和框架当然节假日除外),公众号推文有项目和框架的介绍.功能特点以及部分截图等(打不开或 ...

  3. Gradle安装配置教程

    一.安装前检查 检查电脑上是否安装JDK,如果没有安装,请查看JDK安装教程:点击查看 如果电脑上已经安装JDK,按Win + R键,输入cmd,然后点击确定 输入java -version,点击回车 ...

  4. ipa客户端安装

    ipa客户端安装 安装操作官网 非交互式安装IPa客户端 kinit admin ipa host-find ipa host-add ipa host-add --help ipa host-add ...

  5. C# Wke例子 -- WebUI登录窗口

    概述 Wke介绍: http://blog.csdn.net/sabrecode/article/details/78145938 用Wke做了一个登录窗口, webui比较特殊. 因为它就是一个超文 ...

  6. Solution -「洛谷 P2044」「NOI 2012」随机数生成器

    Description Link. 给你一个递推式,让你求某一项的值模上 \(g\). Solution 这道题正解是矩阵.我这里给出一种分治的做法. 题目中说 $\ \ \ \ \ \ \ $ $\ ...

  7. Solution -「CF 1073G」Yet Another LCP Problem

    Description Link. 给定字符串,正整数集合 \(A,B\),满足 \(\forall u\in A,v\in B,1\le u,v\le n\). 求 \(\sum_{i\in A}\ ...

  8. 彻底解决Chrome“请停用以开发者模式运行的扩展程序”提示(亲测整合)

    本站有大佬已写较全的解决方案(修改dll文件法) 原文链接 但是本人Chrome76版本不适用,匹配不到提示语,在知乎中找到修改注册表的方法可以解决 原文链接 最后附上一个谷歌访问助手吧 链接: ht ...

  9. c语言代码练习3改进

    #define _CRT_SECURE_NO_WARNINGS 1 #include <stdio.h> int main() { int x = 0; printf("请输入一 ...

  10. AI图形算法的应用之一:仪表识别

    目前AI智能算法如火如荼,各大型厂商对此趋之若鹜般加大开发力度,比如大华.海康这些视频处理类,以及百度.腾讯这些IT软件厂商,因为业务开展需要,我也把研发方向转向于此,小有成绩,在此展示一下. 最近研 ...