제출 #1200367

#제출 시각아이디문제언어결과실행 시간메모리
1200367AblablaConstruction Project 2 (JOI24_ho_t2)C++20
0 / 100
1 ms584 KiB
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef pair<ll, ll> pii;

const ll INF = 1e18 + 7;

int main() {
	ll n, m;
	cin >> n >> m;

	ll s, t, l, k;
	cin >> s >> t >> l >> k;
	s--; t--;

	vector<vector<pii>> csucsok(n, vector<pii>());
	for(ll i = 0; i < m; i++){
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;

		csucsok[a].push_back({b, c});
		csucsok[b].push_back({a, c});
	}

	vector<ll> tTol(n, INF);
	vector<bool> bejart(n);
	priority_queue<pii/*, vector<pii>, greater<pii>*/> bejar;
	bejar.push({0, t});
	tTol[t] = 0;

	while(!bejar.empty()){
		ll akt = bejar.top().second;
		bejar.pop();

		if(bejart[akt]) continue;
		bejart[akt] = 1;

		for(pii x : csucsok[akt]){
			if(bejart[x.first]) continue;

			tTol[x.first] = min(tTol[x.first], tTol[akt] + x.second);
			bejar.push({-tTol[x.first], x.first});
		}
	}

	vector<ll> sTol(n, INF);
	bejart.assign(n, 0);
	bejar.push({0, s});
	sTol[s] = 0;

	while(!bejar.empty()){
		ll akt = bejar.top().second;
		bejar.pop();

		if(bejart[akt]) continue;
		bejart[akt] = 1;

		for(pii x : csucsok[akt]){
			if(bejart[x.first]) continue;

			sTol[x.first] = min(sTol[x.first], sTol[akt] + x.second);
			bejar.push({-sTol[x.first], x.first});
		}
	}

	sort(tTol.begin(), tTol.end(), greater<ll>());
	sort(sTol.begin(), sTol.end());

	ll ind = 0;
	ll ans = 0;

	for(ll i = 0; i < n; i++){
		while(ind < tTol.size() && sTol[i] + tTol[ind] + l > k){
			ind++;
		}

		ans += n - ind;
	}

	cout << ans << "\n";
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...