【問題解】P 113雑務


複雑な図論に分類されているが、すべての図論方法を避けることができる不思議な操作思想がある.
https://www.luogu.org/blog/curtis-1020/solution-p1113
図論題をどのようにdpにするか.jpg
#include
#include
#include
#include
#include
using namespace std;
const int maxn=50010;
int t;
int ans[maxn],tot=-1e9;
int main()
{
	cin>>t;
	while(t--)
	{
		int num,l,tmp=0;
		int q; 
		cin>>num>>l;
		while(cin>>q&&q!=0)
		{
			tmp=max(tmp,ans[q]);
		}
		ans[num]=tmp+l;
		tot=max(tot,ans[num]);
	}
	cout<