比赛 NOIP模拟赛by mzx Day2 评测结果 AAWAWWWWWW
题目名称 森林大礼包 最终得分 30
用户昵称 Hexฏ๎๎๎๎๎๎๎๎๎ۣۣۣ 运行时间 0.510 s
代码语言 C++ 内存使用 3.68 MiB
提交时间 2016-10-20 21:37:02
显示代码纯文本
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<algorithm>

const int MOD = 1000000007;

using namespace std;

int a[100005][11],maxn=0;
bool book[100005];

int read(){
	int p=0,f=1;
	char c;
	c=getchar();
	while( c < '0' || c > '9' )
	  {
	  	if( c == '-' )
	  	  f=-1;
	  	c=getchar();
	  }
	while( c <= '9' && c >= '0' )
	  {
	  	p=p*10+(c-'0');
//	  	cout<<p<<endl;
	  	c=getchar();
	  }
	return p*f;
}

int main(int argc,char ** argv){
	freopen("three_squirrels.in","r",stdin);
	freopen("three_squirrels.out","w",stdout);
	int n;
	n=read();

	int i,j,k,t=0;
	for(i=1;i<=n;i++)
	  {
	  	k=read();
	  	a[i][1]=k;
	  	for(j=2;j<=k+1;j++)
	  	  a[i][j]=read();
//	  	cout<<"Fuck♂You!"<<endl;
	  }
	memset(book,false,sizeof(book));
	book[0]=true;
	a[0][1]=0;
	a[0][2]=1;
	for(i=1;i<=n;i++)
	  {
	  	t=0;
//	  	cout<<a[i][1]<<endl;
	  	for(j=2;j<=a[i][1]+1;j++)
	  	  if( book[ a[i][j] ] == false )
	  	    {
	  	      t=0;
	  	      break;
			}
		  else
		    {
		      t += a[ a[i][j] ] [ a[a[i][j]][1] + 2 ] % MOD ;
			}
		if( t != 0 )
		  {
//		  	cout<<2333<<endl;
		  	a[i][ a[i][1] + 2 ] = t;
		  	book[i]=true;
		  }
	  }
	cout<<a[n][ a[n][1] + 2 ];
//	for(i=1;i<=n;i++)
//	  cout<<book[i]<<" ";
//	cout<<endl;
//	cout<<maxn;
	return 0;
}
/*
7
1 0
2 0 1
2 1 2
2 2 3
2 3 4
2 4 5
2 5 6
*/
/*
10
1 0
2 0 1
2 1 2
2 2 3
3 2 3 4
4 1 2 3 4
2 5 6
1 5
3 6 7 8
4 2 3 4 5
*/