题目大意:有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!的更多相关文章

  1. 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 ...

  2. 【codeforces 757C】Felicity is Coming!

    time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...

  3. 【codeforces 757D】Felicity's Big Secret Revealed

    [题目链接]:http://codeforces.com/problemset/problem/757/D [题意] 给你一个01串; 让你分割这个01串; 要求2切..n+1切; 对于每一种切法 所 ...

  4. 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 ...

  5. 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 ...

  6. 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 ...

  7. Codeforces 757C. Felicity is Coming!

    C. Felicity is Coming! time limit per test:2 seconds memory limit per test:256 megabytes input:stand ...

  8. Codeforces Round #391 C. Felicity is Coming!

    题目链接 http://codeforces.com/contest/757/problem/C 题意:给你n组数范围在1-m,可进行变换f(x)=y,就是将所有的x全变成y,最后 要满足变化后每组数 ...

  9. Codeforces 757D - Felicity's Big Secret Revealed

    757D - Felicity's Big Secret Revealed 题目大意:给你一串有n(n<=75)个0或1组成的串,让你划最多n+1条分割线,第一条分割线的前面和最后一条分割线的后 ...

随机推荐

  1. ubuntu上zip格式解压乱码解决

    在windows上压缩的文件,是以系统默认编码中文来压缩文件.由于zip文件中没有声明其编码,所以linux上的unzip一般以默认编码解压,中文文件名会出现乱码. 虽然2005年就有人把这报告为bu ...

  2. JavaScript实战总结

    javascript中数组的22种方法:http://www.cnblogs.com/xiaohuochai/p/5682621.html 1.js闭包 2.eval函数 eval(“字符串”)  将 ...

  3. SQL语句——重复记录

    1.查找重复记录: (按id查找) select * from user_info where id in ( select id from user_info group by id ) 即:sel ...

  4. 【洛谷P1052【NOIP2005提高T2】】过河

    题目描述 在河上有一座独木桥,一只青蛙想沿着独木桥从河的一侧跳到另一侧.在桥上有一些石子,青蛙很讨厌踩在这些石子上.由于桥的长度和青蛙一次跳过的距离都是正整数,我们可以把独木桥上青蛙可能到达的点看成数 ...

  5. HNOI2018游记

    第一次参加本省省选,结果又是一次划水 Day 0 喝了一个小时鸡汤 大家看看人家钱学森(sheng) 竞赛生要多发展些爱好 不要一考完就fake,那种下考说"大佬AC辣!太强啦!月莫月莫月莫 ...

  6. cetus系列~安装和基本配置

    cetus系列一 安装   1 安装软件环境   yum install cmake gcc glib2-devel flex mysql-devel gperftools-libs  bison f ...

  7. iOS视频流开发(2)—视频播放

    承上篇,本篇文章主要介绍iOS视频播放需要用到的类.以及他们的使用场景和开发中遇到的问题. MPMoviePlayerViewController MP简介 iOS提供MPMoviePlayerCon ...

  8. 使用Groovy的mixin方法注入,和mixedIn属性实现过滤链

    mixin方法注入不多说,这里只是用这个属性搞一个过滤器链的功能 假设我现在有个方法,输入一个字符串,然后需求提出需要进行大写转换输出, 过了一天又要加个前缀,再过了一天,需要把一些字符过滤掉.... ...

  9. SpringBoot修改Servlet相关配置

    第一种方式在配置文件中进行修改 server.port=8081 server.servlet.context-path=/springboot server.tomcat.uri-encoding= ...

  10. ubuntu下好用的音乐播放器audacious

    audacious是ubuntu下一款非常好用的音乐播放器,万能的音乐播放器而且简洁美观,可以播放ape各种无损发烧音乐格式. 如果想听音乐的话,现在百度音乐,酷我音乐,酷狗音乐等都是有网络播放器的, ...