#include<bits/stdc++.h>
using namespace std;
const int N = 5005000;
struct edge
{
int to,cost;
};
int T,n,maxx;
int dis[N],vis[N];
vector <edge> p[N];
queue <int> q;
void spfa()
{
for(int i = 1;i <= maxx + 1;i ++)
{
q.push(i);
vis[i] = 1;
}
while(!q.empty())
{
int u = q.front();
q.pop();
vis[u] = 0;
for(int i = 0;i < p[u].size();i ++)
{
int v = p[u][i].to,l = p[u][i].cost;
if(dis[v] < dis[u] + l)
{
dis[v] = dis[u] + l;
if(!vis[v])
{
q.push(v);
vis[v] = 1;
}
}
}
}
}
int main()
{
cin>>T;
for(int j = 0;j < T;j ++)
{
maxx = -1;
cin>>n;
for(int i = 1 + j * 50005;i <= n + j * 50005;i ++)
{
int a,b,c;
cin>>a>>b>>c;
if(b < a)swap(a,b);
p[a].push_back(edge{b + 1,c});
maxx = max(maxx,b);
}
for(int i = 1 + j * 50005;i <= maxx + 1 + j * 50005;i ++)
{
p[i - 1].push_back(edge{i,0});
p[i].push_back(edge{i - 1,-1});
}
spfa();
cout<<dis[maxx + 1 + j * 50005]<<'\n';
}
return 0;
}
样例过了,交上去后一直显示Unknown Err。啥情况啊?