ARC 062 F - Painting Graphs with AtCoDeer 割点 割边 不动点 burnside引理
LINK:Painting Graphs with AtCoDeer
看英文题面果然有点吃不消 一些细节会被忽略掉。
问每条边都要被染色 且一个环上边的颜色可以旋转.
用c种颜色有多少本质不同的方法。
注意这里的环指简单环 即不能经过一个节点两次。
考虑环套环的情况 手玩可以发现 可以将这种情况出现的所有边按顺序放置。
那么只和颜色出现的次数有关 隔板法做即可。
一个环 容易发现可以使用\(burnside\)引理。
割边 也很容易。
难点是求简单环。
不能求割边 因为边双不一定是简单环。
但是点双可以发现是简单环 证明可以感性理解 我也不知道怎么证明。
再跑个割边求就复杂了。这道题特殊性是 无重边无自环。
割边所属的那两个点显然是一个点双 所以这道题中大小为2的点双中间夹的就是割边。
复杂度\(n^2logn\)
code
//#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<ctime>
#include<cctype>
#include<queue>
#include<deque>
#include<stack>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<cstring>
#include<string>
#include<ctime>
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<queue>
#include<deque>
#include<stack>
#include<vector>
#include<algorithm>
#include<utility>
#include<bitset>
#include<set>
#include<map>
#define ll long long
#define db double
#define INF 10000000000000000ll
#define inf 1000000000
#define ldb long double
#define pb push_back
#define put_(x) printf("%d ",x);
#define get(x) x=read()
#define gt(x) scanf("%d",&x)
#define gi(x) scanf("%lf",&x)
#define put(x) printf("%d\n",x)
#define putl(x) printf("%lld\n",x)
#define rep(p,n,i) for(RE int i=p;i<=n;++i)
#define go(x) for(int i=lin[x],tn=ver[i];i;tn=ver[i=nex[i]])
#define fep(n,p,i) for(RE int i=n;i>=p;--i)
#define vep(p,n,i) for(RE int i=p;i<n;++i)
#define pii pair<int,int>
#define mk make_pair
#define RE register
#define P 1000000007ll
#define gf(x) scanf("%lf",&x)
#define pf(x) ((x)*(x))
#define uint unsigned long long
#define ui unsigned
#define EPS 1e-10
#define sq sqrt
#define S second
#define F first
#define mod 1000000007
using namespace std;
char *fs,*ft,buf[1<<15];
inline char gc()
{
return (fs==ft&&(ft=(fs=buf)+fread(buf,1,1<<15,stdin),fs==ft))?0:*fs++;
}
inline int read()
{
RE int x=0,f=1;RE char ch=gc();
while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
return x*f;
}
const int MAXN=55,maxn=110<<2;
int n,m,c,len=1,maxx,top,cc,cnt,T,ans=1;
int fac[maxn],inv[maxn],vis[maxn],mark[maxn],dfn[maxn],low[maxn],s[maxn],g[maxn],q[maxn];
int lin[MAXN],ver[maxn],nex[maxn];
inline void add(int x,int y)
{
ver[++len]=y;
nex[len]=lin[x];
lin[x]=len;
}
inline int ksm(int b,int p)
{
int cnt=1;
while(p)
{
if(p&1)cnt=(ll)cnt*b%mod;
b=(ll)b*b%mod;p=p>>1;
}
return cnt;
}
inline int gcd(int a,int b){return b?gcd(b,a%b):a;}
inline int solve(int n)
{
int sum=0;
rep(1,n,i)sum=(sum+ksm(c,gcd(n,i)))%mod;
sum=(ll)sum*ksm(n,mod-2)%mod;
return sum;
}
inline int C(int a,int b){return a<b?0:fac[a]*(ll)inv[b]%mod*inv[a-b]%mod;}
inline void solve_1(int n)
{
if(n==2)return ++cnt,void();
rep(1,n,i)mark[q[i]]=1;
int sum=0;
rep(1,n,j)
{
for(int k=lin[q[j]];k;k=nex[k])
{
int tn=ver[k];
if(mark[tn])++sum;
}
}
sum=sum>>1;
if(sum==n)ans=(ll)ans*solve(n)%mod;
else ans=(ll)ans*C(c+sum-1,c-1)%mod;
rep(1,n,j)mark[q[j]]=0;
}
inline void dfs(int x)
{
dfn[x]=low[x]=++T;s[++top]=x;
go(x)
{
if(!dfn[tn])
{
dfs(tn);
low[x]=min(low[x],low[tn]);
int tt=0;
if(low[tn]>=dfn[x])
{
int y=0;tt=0;
while(y!=tn)
{
y=s[top--];
q[++tt]=y;
}
q[++tt]=x;
solve_1(tt);
}
}
else low[x]=min(low[x],dfn[tn]);
}
}
int main()
{
//freopen("1.in","r",stdin);
maxx=300;get(n);get(m);get(c);
rep(1,m,i)
{
int get(x),get(y);
add(x,y);add(y,x);
}
fac[0]=1;
rep(1,maxx,i)fac[i]=(ll)fac[i-1]*i%mod;
inv[maxx]=ksm(fac[maxx],mod-2);
fep(maxx-1,0,i)inv[i]=(ll)inv[i+1]*(i+1)%mod;
rep(1,n,i)if(!dfn[i])dfs(i);
ans=(ll)ans*ksm(c,cnt)%mod;
put(ans);return 0;
}
ARC 062 F - Painting Graphs with AtCoDeer 割点 割边 不动点 burnside引理的更多相关文章
- ARC062 - F. Painting Graphs with AtCoDeer (Polya+点双联通分量)
似乎好久都没写博客了....赶快来补一篇 题意 给你一个 \(n\) 个点 , 没有重边和自环的图 . 有 \(m\) 条边 , 每条边可以染 \(1 \to k\) 中的一种颜色 . 对于任意一个简 ...
- [Arc062] Painting Graphs with AtCoDeer
[Arc062] Painting Graphs with AtCoDeer Description 给定一张N点M边的无向图,每条边要染一个编号在1到K的颜色.你可以对一张染色了的图进行若干次操作, ...
- ARC062F AtCoDeerくんとグラフ色塗り / Painting Graphs with AtCoDeer Burnside 引理
题目传送门 https://atcoder.jp/contests/arc062/tasks/arc062_d 题解 首先对整张图做 Tarjan 点双. 对于一个点双,如果是由一条边构成的,那么很显 ...
- AtcoderARC062F Painting Graphs with AtCoDeer 【双连通分量】【polya原理】
题目分析: 如果一个双连通分量是简单环,那么用polya原理计数循环移位即可. 如果一个双连通分量不是简单环,那么它必然可以两两互换,不信你可以证明一下相邻的可以互换. 如果一条边是桥,那么直接乘以k ...
- 【AtCoder】ARC062F - AtCoDeerくんとグラフ色塗り / Painting Graphs with AtCoDeer
题解 考虑一个点双(因为是简单环),如果没有环(两点一线),那么乘上K 如果有一个环,那么用polya定理,每个置换圈有gcd(i,n)个循环节 如果有两个及以上的环,任何一种置换都合法,那么只和每个 ...
- [ARC062F]Painting Graphs with AtCoDeer
题意:一个无向图,用$k$种不同的颜色给每条边染色,问能染出多少种不同的图,如果两张图能通过循环移位环边使得颜色相同,那么这两张图被认为是相同的 数学太差伤不起啊...补了一下Burnside定理的证 ...
- 2018.09.20 atcoder Painting Graphs with AtCoDeer(tarjan+polya)
传送门 一道思维题. 如果没有环那么对答案有k的贡献. 如果恰为一个环,可以用polya求贡献. 如果是一个有多个环重叠的双联通的话,直接转化为组合数问题(可以证明只要每种颜色被选取的次数相同一定可以 ...
- 【ARC062F】 Painting Graphs with AtCoDeer 点双连通分量+polya定理
Description 给定一张N点M边的无向图,每条边要染一个编号在1到K的颜色. 你可以对一张染色了的图进行若干次操作,每次操作形如,在图中选择一个简单环(即不经过相同点的环),并且将其颜色逆时针 ...
- [atARC062F]Painting Graphs with AtCoDeer
求出点双后缩点,对于点双之间,显然不存在简单环,即每一个简单环一定在一个点双内部,换言之即每一个点双可以独立的考虑,然后将结果相乘 (对于点双之间的边任意染色,即若有$s$条边,还会有$k^{s}$的 ...
随机推荐
- Asp.Net Core Blazor之容器部署
写在前面 Docker作为开源的应用容器引擎,可以让我们很轻松的构建一个轻量级.易移植的容器,通过Docker方式进行持续交付.测试和部署,都是极为方便的,并且对于我们开发来说,最直观的优点还是解决了 ...
- 免费馅饼——移动dp
免费馅饼 题目描述 SERKOI最新推出了一种叫做"免费馅饼"的游戏: 游戏在一个舞台上进行.舞台的宽度为 \(W\) 格,天幕的高度为 \(H\) 格,游戏者占一格. 开始时游戏 ...
- 【线型DP】【LCS】洛谷P4303 [AHOI2006]基因匹配
P4303 [AHOI2006]基因匹配 标签(空格分隔): 考试题 nt题 LCS优化 [题目] 卡卡昨天晚上做梦梦见他和可可来到了另外一个星球,这个星球上生物的DNA序列由无数种碱基排列而成(地球 ...
- cmake的下载和安装
背景: 最近迷上了 vscode 编辑器, 快速便捷,而且插件丰富,使用起来很爽.既然这样,本身游戏也是用 mingw 加 cygwin 开发的, 可以配置一下,开搞. 实操: 1.登陆cmake官网 ...
- typeError:The value of a feed cannot be a tf.Tensor object.Acceptable feed values include Python scalars,strings,lists.numpy ndarrays,or TensorHandles.For reference.the tensor object was Tensor...
如上贴出了:错误信息和错误代码. 这个问题困扰了自己两天,报错大概是说输入的数据和接受的格式不一样,不能作为tensor. 后来问了大神,原因出在tf.reshape(),因为网络训练时用placeh ...
- vue axios接口封装、Promise封装、简单的axios方法封装、vue接口方法封装、vue post、get、patch、put方法封装
相信大家在做前后端数据交互的时候都会给请求做一些简单的封装就像之前封装ajax方法一样axios的封装也是一样的简单下面这个就是封装的axios的方法,require.js import axios ...
- express中是如何处理IP的?
express获取client_ip req.ip // 获取客户端ip req.ips // 获取请求经过的客户端与代理服务器的Ip列表 查看源码 定义获取ip的入口, // 源码 request. ...
- Python numpy 浮点数精度问题
Python numpy 浮点数精度问题 在复现FP(fictitious play, Iterative solution of games by fictitious play-page393)算 ...
- echarts 踩坑 : id必须不同
我们可能用react前端框架开发项目. 也就是组件化开发. 一个页面里可能有很多组件. 而echarts是寻找特定ID的DOM去渲染的. 也就是说,如果整个页面.包括所有页面组件,有id相同的DOM, ...
- Markdown与LaTex使用语法整合
Markdown学习 RUNOOB 简介 Markdown 是一种轻量级标记语言,它允许人们使用易读易写的纯文本格式编写文档. Markdown 语言在 2004 由约翰·格鲁伯(英语:John Gr ...