WA on #15,样例全过求调
查看原帖
WA on #15,样例全过求调
542128
liyixin0514楼主2024/2/27 15:40

与官方题解做法相符。

RT,95pts

\thx orz

孩子快调疯了

#include<bits/stdc++.h>
#define sf scanf
#define pf printf
#define il inline
using namespace std;
typedef long long ll;
const int N=5e5+2,inf=2e9+7;

int n,m,s;
int u;
struct edge{
	int to,c,l,r;
	bool operator<(const edge b)const{
		return c>b.c;
	}
};
set<edge> e[N][22];
bool del[N];
int t[N];
int ans;
edge p[N];

struct qu{
	int u,l,r;
};
void bfs(){
	queue<qu> que;
	que.push({s,0,0});
	while(!que.empty()){
		int u=que.front().u,L=que.front().l,R=que.front().r;
		t[u]=min(t[u],R);
//		pf(" %d\n",u);
		que.pop();
		for(int i=1;i<=(L==0?20:L);i++){
			int num=0;
			for(edge j:e[u][i]){
				int v=j.to,c=j.c,l=j.l,r=j.r;
//				pf("  %d\n",v);
				if(c<R) break;
				que.push({v,l,r});
				p[++num]=j;
//				e[u][i].erase(j);
			}
			while(num){
				e[u][i].erase(p[num]);
				num--;
			}
		}
	}
}

int main(){
//	freopen("wind2.in","r",stdin);
//	freopen("wind.out","w",stdout);
	sf("%d%d%d",&n,&m,&s);
	for(int i=1;i<=n;i++) t[i]=inf;
	for(int i=1;i<=m;i++){
		sf("%d",&u);
		int to,o,c,l,r;
		sf("%d%d%d%d%d",&to,&o,&c,&l,&r);
		e[u][o].insert({to,c,l,r});
	}
	bfs();
//	pf("OK\n");
//	t[s]=0;
	for(int i=1;i<=n;i++){
		if(t[i]==inf) t[i]=0;
		ans=max(ans,t[i]);
	}
	pf("%d\n",ans);
}

2024/2/27 15:40
加载中...