记录编号 |
326989 |
评测结果 |
AAAAAAAAAA |
题目名称 |
森林大礼包 |
最终得分 |
100 |
用户昵称 |
Riolu |
是否通过 |
通过 |
代码语言 |
C++ |
运行时间 |
1.202 s |
提交时间 |
2016-10-21 18:39:41 |
内存使用 |
2.60 MiB |
显示代码纯文本
/*=========================================*
* Auther: Riolu
* Time: 2016.1
* Picture:
* Web:
* ©Copyright 2016 Riolu. All Rights Reserved.
*=========================================*/
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
typedef long long ll;
const int N =1e5;
int n;
vector<int> a[N];
int t[N],M=1e9+7;
void read(){
freopen("three_squirrels.in","r",stdin);
freopen("three_squirrels.out","w",stdout);
//ios::sync_with_stdio(false);
//scanf("%d",&n);
}
ll ans[N];
int dfs(int x){
//cout<<x<<endl;
if(ans[x])return ans[x];
ll k=0;
for(int i=0;i<t[x];i++){
//cout<<x<<' '<<a[x][i]<<endl;
k+=dfs(a[x][i]);
k%=M;
}
ans[x]=k;
//cout<<x<<' '<<ans[x]<<endl;
return k;
}
int main(){
read();
scanf("%d",&n);
int k,i,j;
for(i=1;i<=n;i++){
scanf("%d",&t[i]);
for(j=0;j<t[i];j++){
scanf("%d",&k);
a[i].push_back(k);
}
}
//cout<<M<<endl;
ans[0]=1;
cout<<dfs(n)<<endl;
return 0;
}
/*
*/