比赛 NOIP模拟赛by mzx Day2 评测结果 AAAAAAAWWW
题目名称 森林大礼包 最终得分 70
用户昵称 Tiny 运行时间 0.140 s
代码语言 C++ 内存使用 135.60 MiB
提交时间 2016-10-20 19:05:49
显示代码纯文本
#include <stdio.h>

const int MAXS = 150 * 1024 * 1024;
int buf_cnt = 0;
char read_buf[MAXS];

template <typename T> inline void Read_buf(T &num) {
	num = 0; bool minus = false;
	while (read_buf[buf_cnt] < '-' || read_buf[buf_cnt] > '9') ++buf_cnt;
	if (read_buf[buf_cnt] == '-') { minus = true; ++buf_cnt; }
	while (read_buf[buf_cnt] >= '0' && read_buf[buf_cnt] <= '9')
		num = num * 10 + read_buf[buf_cnt++] - '0';
	if (minus) num = -num;
}

template <typename T> inline void Read(T &num) {
	num = 0; char ch; bool minus = false;
	while (ch = getchar(), ch < '-' || ch > '9');
	if (ch == '-') { minus = true; ch = getchar(); }
	while (num = num * 10 + ch - '0', ch = getchar(), ch >= '0' && ch <= '9');
	if (minus) num = -num;
}

#define MOD 1000000007

int a[100010] = {1};

int main() {
 #define SUBMIT
 #ifdef SUBMIT
	freopen("three_squirrels.in", "r", stdin);
	freopen("three_squirrels.out", "w", stdout);
	fread(read_buf, 1, MAXS, stdin);
 #endif

	int n; Read_buf(n);
	for (int i = 1, m, t; i <= n; ++i) {
		Read_buf(m);
		while (m--) {
			Read_buf(t);
			a[i] = (a[i] + a[t]) % MOD;
		}
	}
	printf("%d\n", a[n]);

 #ifndef SUBMIT
	puts("\n--------------------");
	getchar(); getchar();
 #else
	fclose(stdin); fclose(stdout);
 #endif
	return 0;
}