题目大意:有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. awk词频统计功能

    [root@test88 ~]# vim word_freq.sh #!/bin/bash if [ $# -ne 1 ];then echo "Usage: $0 filename&quo ...

  2. ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password:NO)

    转自:http://blog.sina.com.cn/s/blog_586a1f3e01000b82.html 刚使用mysql, 就老是碰到这个问题,真是郁闷, 终于找到原因.. C:\Progra ...

  3. Linux - vim 编辑器

    gconf-editor # 配置编辑器 /etc/vimrc # 配置文件路径 vim +24 file # 打开文件定位到指定行 vim file1 file2 # 打开多个文件 vim -O2 ...

  4. 第5月第6天 NSOperation isConcurrent category同名覆盖

    1. @implementation AFURLConnectionOperation ... - (BOOL)isConcurrent { return YES; } NSOperation调用st ...

  5. Sqoop异常:Exception in thread "main" java.lang.NoClassDefFoundError: org/json/JSONObject

    18/12/07 01:09:03 INFO mapreduce.ImportJobBase: Beginning import of staffException in thread "m ...

  6. chrome面板介绍

    Chrome开发者工具详解(1):Elements.Console.Sources面板 Chrome 开发者工具详解(2):Network 面板 Chrome开发者工具详解(3):Timeline面板 ...

  7. 【转】Python之函数进阶

    [转]Python之函数进阶 本节内容 上一篇中介绍了Python中函数的定义.函数的调用.函数的参数以及变量的作用域等内容,现在来说下函数的一些高级特性: 递归函数 嵌套函数与闭包 匿名函数 高阶函 ...

  8. python中argparse模块用法实例详解

    python中argparse模块用法实例详解 这篇文章主要介绍了python中argparse模块用法,以实例形式较为详细的分析了argparse模块解析命令行参数的使用技巧,需要的朋友可以参考下 ...

  9. 简述JavaScript全局对象

    全局对象是JavaScript中非常重要的一类对象,它作为程序顶层(程序最顶端,不包括在任何函数之内)的上下文存在,JavaScript中的全局属性.全局函数都是通过全局对象来提供给程序的,比如 全局 ...

  10. 安装VNC

    一.安装相应桌面环境与vnc服务端和客户端: # yum groupinstall "GNOME Desktop Environment"(CentOS 5.x安装GNOME桌面环 ...