fork download
  1. #include <bits/stdc++.h>
  2. #define ll long long
  3. #define pb push_back
  4. #define maxn 100010
  5. #define mmaxn 1000000000
  6. #define pii pair<int,int>
  7. #define pll pair<ll int,ll int>
  8. #define pdd pair<double,double>
  9. #define MOD 1000000007
  10. #define f first
  11. #define s second
  12. using namespace std;
  13. ll int factmod ( int n, ll int p ) {
  14. ll int ans=1;
  15. for(int i=1;i<=n;i++)
  16. ans = (ans*i) %p;
  17. return ans % p;
  18. }
  19. int main(){
  20. ios_base::sync_with_stdio(0);
  21. int n,m,g;
  22. cin>>n>>m;
  23. vector<string> poke(m+1,"");
  24. for(int i=0;i<n;i++){
  25. cin>>g;
  26. vector<int> x(g);
  27. map<int,int> y;
  28. for(int j=0;j<g;j++){
  29. cin>>x[i];
  30. y[x[i]]++;
  31. }
  32. for(int j=1;j<=m;j++){
  33. poke[j]+=to_string(y[j]);
  34. }
  35. }
  36. map<string,int> z;
  37. for(auto i:poke){
  38. // cout<<i<<"\n";
  39. int flag=0;
  40. for(int j=0;j<i.length();j++){
  41. if(i[j]!='0'){
  42. flag=1;
  43. break;
  44. }
  45. }
  46. if(i!="" && flag==1)
  47. z[i]++;
  48. }
  49. ll int ans=1;
  50. for(auto i:z){
  51. // cout<<i.f<<" "<<i.s<<"\n";
  52. ans*= factmod(i.s,MOD);
  53. ans%=MOD;
  54. }
  55. cout<<ans<<"\n";
  56. }
Success #stdin #stdout 0s 3472KB
stdin
3 7
2 1 2
2 3 4
3 5 6 7
stdout
24