hdu5399 Too Simple

Problem Description
Rhason Cheung had a simple problem, and asked Teacher Mai for help. But Teacher Mai thought this problem was too simple, sometimes naive. So she ask you for help.

Teacher Mai has m functions f1,f2,,fm:{1,2,,n}{1,2,,n} (that means for all x{1,2,,n},f(x){1,2,,n} ). But Rhason only knows some of these functions, and others are unknown.

She wants to know how many different function series f1,f2,,fm there are that for every i(1in) , f1(f2(fm(i)))=i . Two function series f1,f2,,fm and g1,g2,,gm are considered different if and only if there exist i(1im),j(1jn) , fi(j)gi(j) .
 

Input
For each test case, the first lines contains two numbers n,m(1n,m100) .

The following are m lines. In i -th line, there is one number 1 or n space-separated numbers.

If there is only one number 1 , the function fi is unknown. Otherwise the j -th number in the i -th line means fi(j) .
 

Output
For each test case print the answer modulo 109+7 .
 

Sample Input
  
  
3 3 1 2 3 -1 3 2 1
 

Sample Output
 
 
1
Hint
The order in the function series is determined. What she can do is to assign the values to the unknown functions.

解答:

这道题目比赛那会已经想出来规律,队友去敲的代码,只是注意几点小地方就行。判断有没有一行中有重复的数字。如果不存在-1,判断是不是符合那个条件。


害羞

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值