C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output — This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii-chan! With h…
题目链接:http://codeforces.com/problemset/problem/869/C 题意: 红色.蓝色.紫色的小岛分别有a,b,c个. 你可以在两个不同的岛之间架桥,桥的长度为1. 任意两个颜色相同的岛之间的距离不能小于3. 问你合法的架桥方案数. 题解: 显然只能在不同颜色的岛之间连边. 而且一个岛对于一种颜色,最多只能连一个岛. 设f(x,y)表示两种颜色的岛相互连边,分别有x,y个,连边的方案数.(x < y) 那么ans = f(a,b) * f(b,c) * f(a…
题意:有三个集合,分别含有a.b.c个点,要求给这些点连线,也可以全都不连,每两点距离为1,在同一集合的两点最短距离至少为3的条件下,问有多少种连接方案. 分析: 1.先研究两个集合,若每两个集合都保证满足条件,那最后结果一定满足条件. 2.两个集合间若要最短距离至少为3,那每个集合中的点只能同时与另一个集合中的一个点相连. 假设两个集合间需要连k条线,则可以在集合A中选k个点,在集合B中选k个点,共有k!种连接方式,即C[A][k] * C[B][k] * k!. 两个集合间最少可连0条,最多…
题意:有三种颜色的岛屿各a,b,c座,你可以在上面建桥.联通的点必须满足以下条件:1.颜色不同.2.颜色相同且联通的两个点之间的最短路径为3 其实之用考虑两种颜色的即可,状态转移方程也不难推出:F[i][j]=F[i-1][j]+j*F[i-1][j-1].答案就是F[a][b]*F[a][c]*F[b][c] #include<bits/stdc++.h> using namespace std; #define MAXN 5000+10 #define MODD 998244353 typ…
题意:有三种三色的岛,用a,b,c来标识这三种岛.然后规定,同种颜色的岛不能相连,而且同种颜色的岛不能和同一个其他颜色的岛相连.问有多少种建桥的方法. 题解:em....dp.我们先看两个岛之间怎么个连法.由题意可得岛与岛之间的链接是单射,我们定义f[a][b],表示有a个颜色1的岛和b个颜色2的岛想连的方案数. 首先当a==1 || b==1的时候 f[a][b]=(b+1)或者 (a+1).然后尝试去找状态转移方程,我们对一个岛去连接另一个岛只有连或者不连两种状态,那么对于不连的状态为f[a…
C. The Intriguing Obsession 题目链接http://codeforces.com/contest/869/problem/C 解题心得:     1.由于题目中限制了两个相同颜色的点之间长度至少为3,这样就只能两两不同颜色的点相互组合,再将三种组合情况的可能种数乘起来.     2.然后就是两个不同颜色的点怎么组合的问题,这就是一个记忆化搜索(DP),假如红色点和黄色点相互组合,这样一个红色点可以对应一个黄色点(dp[x][y] = dp[x-1][y-1]*y),或者…
2018年11月30日更新,补充了一些思考. 题意(CodeForces 869C) 三堆点,每堆一种颜色:连接的要求是同色不能相邻或距离必须至少3.问对整个图有几种连接方法,对一个数取模. 解析 要求很重要:同色不能相邻很容易理解,但是>=3比较难理解.比较常见的是R->G->B->R,这样能看出来一个重要的结论:对单个节点只能连接某个颜色至多一个点(不然一定有距离为2的点).这样一来我们思考一下状态会和哪些东西有关联:如果我放一个一个新颜色在里面,它会怎么同原图产生联系?一是和…
C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output — This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii-chan! With h…
C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output — This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii-chan! With h…
题目描述 — This is not playing but duty as allies of justice, Nii-chan! — Not allies but justice itself, Onii-chan! With hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for som…