【CF Round 439 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 hands joined, go everywhere at a speed faster than our thoughts! This time, the Fire Sisters — Karen and Tsukihi — is heading for somewhere they've never reached — water-surrounded islands!
There are three clusters of islands, conveniently coloured red, blue and purple. The clusters consist of a, b and c distinct islands respectively.
Bridges have been built between some (possibly all or none) of the islands. A bridge bidirectionally connects two different islands and has length 1. For any two islands of the same colour, either they shouldn't be reached from each other through bridges, or the shortest distance between them is at least 3, apparently in order to prevent oddities from spreading quickly inside a cluster.
The Fire Sisters are ready for the unknown, but they'd also like to test your courage. And you're here to figure out the number of different ways to build all bridges under the constraints, and give the answer modulo 998 244 353. Two ways are considered different if a pair of islands exist, such that there's a bridge between them in one of them, but not in the other.
Input
The first and only line of input contains three space-separated integers a, b and c (1 ≤ a, b, c ≤ 5 000) — the number of islands in the red, blue and purple clusters, respectively.
Output
Output one line containing an integer — the number of different ways to build bridges, modulo 998 244 353.
Examples
input
1 1 1
output
8
input
1 2 2
output
63
input
1 3 5
output
3264
input
6 2 9
output
813023575
Note
In the first example, there are 3 bridges that can possibly be built, and no setup of bridges violates the restrictions. Thus the answer is23 = 8.
In the second example, the upper two structures in the figure below are instances of valid ones, while the lower two are invalid due to the blue and purple clusters, respectively.
【翻译】给出三种颜色的点的数目a,b,c,现在连边建图,要求:同种颜色点之间距离大于等于3(无法通达也可以),求构图方案数。
题解:
①关键结论是两个颜色点的连边和另一种颜色无关。
②直接对两种颜色dp:
设f[i][j]表示有i个1号颜色的点,j个2号颜色的点的构图方案数。
转移来源表示新加入的2颜色的点是否连边:
f[i][j]=f[i][j-1]+f[i-1][j-1]*i
③最终答案:f[a][b]*f[a][c]*f[b][c]
#define M 998244353
#define ll long long
#include<bits/stdc++.h>
#define go(i,a,b) for(int i=a;i<=b;i++)
const int N=5003;
ll f[N][N];
int a,b,c,n;
int main()
{
scanf("%d%d%d",&a,&b,&c);
n=std::max(a,std::max(b,c));
go(i,1,n)f[i][0]=f[0][i]=1;f[0][0]=1;
go(i,1,n)go(j,1,n)f[i][j]=(f[i][j-1]+f[i-1][j-1]*i)%M;
printf("%d",((f[a][b]*f[b][c])%M*f[a][c])%M);return 0;
}//Paul_Guderian
寻找生命的意义真的并不容易,
那是件辛酸而伟大的事情。——————汪峰《改变》
【CF Round 439 C. The Intriguing Obsession】的更多相关文章
- 【CF Round 439 E. The Untended Antiquity】
time limit per test 2 seconds memory limit per test 512 megabytes input standard input output standa ...
- 【CF Round 439 B. The Eternal Immortality】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF Round 439 A. The Artful Expedient】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- Codeforces Round #439 C. The Intriguing Obsession
题意:给你三种不同颜色的点,每种若干(小于5000),在这些点中连线,要求同色的点的最短路大于等于3或者不连通,求有多少种连法. Examples Input 1 1 1 Output 8 Input ...
- code forces 439 C. The Intriguing Obsession
C. The Intriguing Obsession time limit per test 1 second memory limit per test 256 megabytes input s ...
- 【Codeforces Round #439 (Div. 2) C】The Intriguing Obsession
[链接] 链接 [题意] 给你3种颜色的点. 每种颜色分别a,b,c个. 现在让你在这些点之间加边. 使得,同种颜色的点之间,要么不连通,要么连通,且最短路至少为3 边是无向边. 让你输出方案数 [题 ...
- 【codeforces】【比赛题解】#869 CF Round #439 (Div.2)
良心赛,虽然我迟了半小时233333. 比赛链接:#869. 呃,CF的比赛都是有背景的……上次是<哈利波特>,这次是<物语>…… [A]巧妙的替换 题意: Karen发现了石 ...
- 【CF Round 434 B. Which floor?】
time limit per test 1 second memory limit per test 256 megabytes input standard input output standar ...
- 【CF Round 434 A. k-rounding】
Time limit per test1 second memory limit per test 256 megabytes input standard input output standard ...
随机推荐
- 10^9以上素数判定,Miller_Rabin算法
#include<iostream> #include<cstdio> #include<ctime> #include<string.h> #incl ...
- 腾讯云负载均衡CLB
负载均衡 使用场景: ①购买一个负载均衡LB实例 ②一级.二级域名都解析到VIP上 ③创建HTTP/HTTPS监听器 ④绑定云主机 在nginx中只需要配置好伪静态和相关设置就ok了
- 初试PHP连接sql server
最开始想使用 pdo_sqlsrv 拓展,但是一直没成功,本文采用的是 pdo_dblib + freetds. 环境:CentOS 6.8.PHP 5.6.20 freetds wget ftp:/ ...
- 使用shell脚本依据分区信息分批次的下载hive表格数据
今天的业务场景大概是这样的,我想把hive表格下载到本地文件系统,然后把这个文件传送到另一个服务器上. 但是这个业务场景一个核心问题就是说我本地机器内存有限,hive表格大概是70G,我是不可能全部下 ...
- 01 mysql 基础一 (进阶)
mysql基础一 1.认识mysql与创建用户 01 Mysql简介 Mysql是最流行的关系型数据库管理系统之一,由瑞典MySQLAB公司开发,目前属于Oracle公司. MySQL是一种关联数据库 ...
- Python的循环正确的操作使用方法详解
要计算1+2+3,我们可以直接写表达式: >>> 1 + 2 + 3 6 要计算1+2+3+...+10,勉强也能写出来. 但是,要计算1+2+3+...+10000,直接写表达式就 ...
- stark组件(4):列表定义列,展示数据库数据
效果图: 一.Stark组件 stark/service/core_func.py from django.urls import re_path from django.shortcuts impo ...
- 搭建一个简单的dns缓存服务器
环境:linux 软件:bind97,bind97-utils, bind97-libs ip:192.168.192.130:192.168.192.131 -------------------- ...
- 通过Aspose.Word和ZXING生成复杂的WORD表格
1.前言 这是我之前做的一个项目中要求的功能模块,它的需求是生成一个WORD文档,需要每页一个表格并且表格中需要插入文字.条形码和二维码等信息,页数可控制.具体的效果如下图所示: 可以看到有以下几点是 ...
- KEIL里如何实现仿真 查看输出波形
1首先打开keil软件 ,点击options 我们选择在debug 2 点击debug 红色的按钮 3 进入调试界面后 ,打开logic analysis窗口 4 打开窗口后 进入setup 4 会弹 ...