C语言的代码,Super Mario

Problem Description
The Mario series is a series of highly popular and acclaimed video games by Nintendo, featuring Nintendo's mascot Mario and, in many games, his brother Luigi and his best friend Yoshi. Gameplay in the series often centers around jumping on and defeating enemies. The games usually feature simple plots; the most common theme is that of Bowser, the primary antagonist, kidnapping Princess Peach, whom Mario saves. Despite the plots usually being very simple, the Mario role-playing games tend to have deeper plots, often involving enemies other than Bowser (many of which involve Bowser actually teaming up with Mario), with aspirations for world domination. Mario has been featured in 200 games, and the series has sold over 200 million copies total, making it the best-selling video game series of all time.

Today,Mario comes to a forest,whick has many apple trees.These trees are special,the apples are grown in the nodes of the tree,whick is shown as follow.

Numbers in the nodes indicate the amount of apples which are also in this node. The root of a tree is also considered as a node too.
There are many trees in this forest, and some trees are connect by one-way road.

Mario is start at a root, and he can jump along the branches up or down. Before each jump, he has to eat an apple, and after he eat an apple he have to jump up or down. Mario can walk along the roads too. He can walk along a road with at most an apple, or without any apple. These walks need not any apples. He can finish his journey at any root. All the nodes, including normal node and root node, are numbered together from 1 to M.
How many apples is Mario able to eat at most?

Input
Multiple cases, you need process to EOF.
First line contains N, M and S, where N indicates the number of roots, M indicates the number of nodes, and S indicates the start root’s number. 0< N<M <= 20000, S is in the range of [1, M].

Every next N lines contains “ID T A1 … AT”, where ID indicates a node-number of root. T indicates the number of roots ID connect to, and A1 to AT is the node-number of these T roots. ID is in the range of [1, M]; T is in the range of [0, M]; A1 to AT is in the range of [1, N]. Integers in every line are split by single space.

Next M lines describe the M nodes. The i th line describe the i th node, and is formatted as: “AppleAmouts T B1 … BT”. Where AppleAmouts indicates the amount of apple in this node, T indicates the number of nodes this node connect with by branches, and B1 to BT indicate the number of these T nodes. AppleAmounts is in the range of [0, 1000]; T is in the range of [0, M-1]; B1 to BT is in the range of [1,M]. Integers in a line are split by a single space.

Output
Print the number that how many apple Mario can eat at most.

Sample Input
2 5 1
1 1 4
4 0
1 2 2 3
5 1 1
5 1 1
5 1 5
0 1 4

2 5 1
1 1 3
3 0
1 1 2
1 1 1
0 1 4
3 2 3 5
2 1 4

Sample Output
2
6

Csdn user default icon
上传中...
上传图片
插入图片
抄袭、复制答案,以达到刷声望分或其他目的的行为,在CSDN问答是严格禁止的,一经发现立刻封号。是时候展现真正的技术了!
立即提问

相似问题

1
java中super代表父类存储空间的标识(可以理解为父类引用)
2
代码里有super.onCreate()为什么报错没有
1
一个关于C语言向量计算方面数据结构的算法的问题,采用C语言
0
符号判断、计算的一种算法问题,如何利用C语言的编程的方法去解决
1
因数质因数的分解的问题的算法怎么利用C语言的程序来实现的呢?
0
十进制的数字对应的罗马数字字母的计算,怎么使用C程序语言代码高效实现的算法?
1
c语言字符串问题,关于strlen与sizeof
0
输出二维平面凸多边形的问题,使用C程序的代码设计的方式和步骤来计算的实现的思路
0
错误的曲线的标注问题,怎么使用C语言的程序的编写过程的方式有效实现的代码怎么写
0
轻松计算出达到目标的最短时间,怎么采用C语言的程序设计的技术的办法来实现这个程序的
4
JAVA 中 子类继承父类方法后 无法获取想要获得的父类参数
1
关于Glide第一加载显示不出图片的问题。
1
本人写的贪吃蛇代码,求教大神哪里错了?
2
pytorch训练LSTM模型的代码疑问
1
各位大神帮忙看下我的代码哪里错了,调试时每次都是显示下载失败。
1
请问大家,我写了一个使用DOWNLOAD MANAGER下载文件的代码,为什么调试的时候总是下载失败呢?
0
Quelling Blade运用C语言的实现
1
正在学习android的第一行代码的coolweather遇到了点问题
0
Brilliant Programmers Show的C语言解决方式
0
C语言进行编程实现Sparrow,具体的过程?