RE求条
查看原帖
RE求条
784202
MarshmallowDream楼主2024/11/10 09:39
#include <iostream>
#include <cstdio>
#include <vector>
#include <climits>
#include <cstring>
using namespace std;
int w,n,m; 
int s,t,v;
int su[15];
int main()
{
	cin>>w;
	while(w--)
	{
		memset(su,0,sizeof(su));
		bool flag=0;
		cin>>n>>m;
		for(int i=1;i<=m;i++)
		{
			cin>>s>>t>>v;
			if(su[t]==0)
			{
				if(s-1>=0)
				{
					su[t]=v+su[s-1];
				}
				else
				{
					su[t]=v;
				}
			}
			else
			{
				if(s-1>=0)
				{
					if(v+su[s-1]!=su[t])
					{
						cout<<"false"<<endl;
						flag=1;
						break;
					}
				}
				else
				{
					if(v!=su[t])
					{
						cout<<"false"<<endl;
						flag=1;
						break;
					}
				}
			}
		}
		if(flag)
		{
			continue;
		}
		cout<<"true"<<endl;
	}
	return 0;
}

教练讲前缀和以后让我们做这道题,但是RE,哪位大佬能帮看看,Subtask1全过,但是Subtask0 RE一大片……
提交记录

2024/11/10 09:39
加载中...