首页 > 其他 > 详细

Codeforces 757C - Felicity is Coming!

时间:2017-08-16 16:10:46      阅读:246      评论:0      收藏:0      [点我收藏+]

757C - Felicity is Coming!

思路:对于不同种类的宝可梦,如果他们所在的gym完全一样那么他们就可以互相进化成对方的种类。还有宝可梦可以进化后种类不变。设有n种所在gym完全一样的宝可梦,那么对于这种gym组合来说,有n!种可供选择的进化方案。

代码:

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset((a),(b),sizeof(a))
const int MOD=1e9+7;
const int N=1e6+5;
vector<int>s[N];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m,a,b;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>a;
        while(a--)
        {
            cin>>b;
            s[b].pb(i);
        }
    }
    
    sort(s+1,s+m+1);//二维vector的排序,每行按第一个数字的大小排序,而且每一行中的元素都从小到大排好序 
    ll cnt=1,ans=1;
    for(int i=2;i<=m;i++)
    {
        if(s[i]==s[i-1])
        {
            cnt++;
            ans=(ans*cnt)%MOD;
        }
        else cnt=1;
    }
    cout<<ans<<endl;
    return 0;
}

 

Codeforces 757C - Felicity is Coming!

原文:http://www.cnblogs.com/widsom/p/7373505.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!