比赛 |
NOIP模拟赛by mzx Day2 |
评测结果 |
MMMMMMMMMM |
题目名称 |
森林大礼包 |
最终得分 |
0 |
用户昵称 |
mybing |
运行时间 |
0.000 s |
代码语言 |
C++ |
内存使用 |
0.00 MiB |
提交时间 |
2016-10-20 20:46:52 |
显示代码纯文本
- #include<iostream>
- #include<cstdio>
- #include<iomanip>
- #include<string>
- #include<cstring>
- #include<algorithm>
- using namespace std;
- int a,x[100000],p,w[10000],q[10000][10000],h[10000]={0},t=0;
- int wx=1000000007;
- int main()
- {
- freopen("three_squirrels.in","r",stdin);
- freopen("three_squirrels.out","w",stdout);
- cin>>a;
- x[0]=1;
- h[0]=1;
- for(int i=1;i<=a;i++)
- {
- cin>>w[i];
- for(int j=1;j<=w[i];j++)
- cin>>q[i][j];
- }
- for(int k=1;k<=a;k++)
- {
- for(int i=1;i<=a;i++)
- {
- t=0;
- if(h[i]==1) continue;
- for(int j=1;j<=w[i];j++)
- {
- if(h[q[i][j]]==1) t++;
- }
- if(t==w[i])
- {for(int j=1;j<=w[i];j++)
- {x[i]=((x[i]%wx)+(x[q[i][j]]%wx))%wx;}
- h[i]=1;
- }
- }
- int l=0;
- for(int i=1;i<=a;i++)
- {
- if(h[i]==1) l++;
- }
- if(l==a) break;
- }
- cout<<x[a]<<endl;
- return 0;
- }