Codeforces 757 C Felicity is Coming!
题目大意:有n个训练营,m种宠物,每个训练营里里面有gi 个宠物,现在每只宠物都要完成一次进化,种类
相同的宠物进化之后,种类还是相同,种类不同的宠物不能进化成相同种类,且要求所有宠物进化之后,每个
训练营各个种类的宠物数量不变。
思维题
思路:我们不能一个一个训练营考虑,我们要考虑不同种类宠物的情况,我们统计每种宠物出现在那个训练营
里面且出现几次,统计结果完全一样的宠物种类分为一堆,这一堆里面的宠物如果有x个,则这堆的贡献为x!
将所有堆得结果想乘就是结果。
原来将vector<int> vec[ N ] 排序,sort(vec,vec+N),是每个按字典序排序,学到了。
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e6+;
const ll mod=1e9+;
int n,m;
ll f[N];
vector<int> cnt[N];
int main()
{
cin>>n>>m;
f[]=;
for(ll i=;i<=m;i++) f[i]=(f[i-]*i)%mod;
for(int i=;i<=n;i++)
{
int g; scanf("%d",&g);
while(g--)
{
int w; scanf("%d",&w);
cnt[w].push_back(i);
}
}
sort(cnt+,cnt++m);
int c=;
ll ans=;
for(int i=;i<=m;i++)
{
if(cnt[i]==cnt[i-])
{
c++;
if(i==m) ans=(ans*f[c])%mod;
}
else
{
ans=(ans*f[c])%mod;
c=;
}
}
cout<<ans<<endl;
return ;
}
Codeforces 757 C Felicity is Coming!的更多相关文章
- Codeforces 757 D. Felicity's Big Secret Revealed 状压DP
D. Felicity's Big Secret Revealed The gym leaders were fascinated by the evolutions which took pla ...
- 【codeforces 757C】Felicity is Coming!
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- 【codeforces 757D】Felicity's Big Secret Revealed
[题目链接]:http://codeforces.com/problemset/problem/757/D [题意] 给你一个01串; 让你分割这个01串; 要求2切..n+1切; 对于每一种切法 所 ...
- Codeforces 757 E Bash Plays with Functions
Discription Bash got tired on his journey to become the greatest Pokemon master. So he decides to ta ...
- Codeforces 757 F Team Rocket Rises Again
Discription It's the turn of the year, so Bash wants to send presents to his friends. There are n ci ...
- Codecraft-17 and Codeforces Round #391 (Div. 1 + Div. 2, combined)D. Felicity's Big Secret Revealed
题目连接:http://codeforces.com/contest/757/problem/D D. Felicity's Big Secret Revealed time limit per te ...
- Codeforces 757C. Felicity is Coming!
C. Felicity is Coming! time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...
- Codeforces Round #391 C. Felicity is Coming!
题目链接 http://codeforces.com/contest/757/problem/C 题意:给你n组数范围在1-m,可进行变换f(x)=y,就是将所有的x全变成y,最后 要满足变化后每组数 ...
- Codeforces 757D - Felicity's Big Secret Revealed
757D - Felicity's Big Secret Revealed 题目大意:给你一串有n(n<=75)个0或1组成的串,让你划最多n+1条分割线,第一条分割线的前面和最后一条分割线的后 ...
随机推荐
- string中substr,find函数使用
2.string函数 find:某子串的起始位(0开始),函数的第二个参数使用代表从该位开始的后缀 substr:1) x开始的连续y位 2) x开始的后缀 #include<bits/stdc ...
- Netty入门(3) - ChannelHandler
ChannelPipeline ChannelHandler实例的列表,用于处理或者截获通道的接收和发送数据,让用户可以在ChannelPipeline中完全控制一个事件以及处理ChannelHand ...
- POJ1236 Network of Schools【强连通】
题意: N(2<N<100)各学校之间有单向的网络,每个学校得到一套软件后,可以通过单向网络向周边的学校传输,问题1:初始至少需要向多少个学校发放软件,使得网络内所有的学校最终都能得到软件 ...
- HDU小小练
hdu1253胜利大逃亡(bfs) 题意:就是城堡问题,找出可通行路径即可 思路:三维BFS,设定前后上下左右6个方向搜索,注意开始的时候人站的位置可以是墙. hdu1495非常可乐(bfs) 题意: ...
- Django学习手册 - ORM choice字段 如何在页面上显示值
在module操作过程中使用choice字段: 核心: obj.get_字段名_display 定义module 数据结构: class msg(models.Model): choice = ( ( ...
- Debian 无线网卡驱动问题
参考这里:https://wiki.debian.org/iwlwifi Debian 9 "Stretch" Add a "non-free" compone ...
- 蒙特卡罗定位(Particle Filter Localization)笔记
善始善终,这篇文章是Coursera课程Robotics: Estimation and Learning最后一周的课程总结.里面的小哥讲得不是很清晰,留下的作业很花功夫(第二周课程也是酱紫). 这周 ...
- ubuntu 14.04 软件中心闪退解决方案
法一: gksudo gedit /usr/share/software-center/softwarecenter/ui/gtk3/views/lobbyview.py 注释下面这句话(注释使用#号 ...
- android camera(一):camera模组CMM介绍【转】
转自:https://blog.csdn.net/kevinx_xu/article/details/8821818 androidcmm图像处理工作手机三星 关键词:android camera ...
- 使用 GDebi 默认代替 Ubuntu 软件中心
GDebi,一个安装 Debian 可执行文件的专用程序.它极其轻量,且专注于安装 .deb 文件,可以自动解决依赖问题,比原生的好用.GDebi 最有用的功能是它也可以为你展示出将要安装的程序的依赖 ...