Submission #1094179

#TimeUsernameProblemLanguageResultExecution timeMemory
1094179Marco_EscandonConstruction Project 2 (JOI24_ho_t2)C++11
45 / 100
2097 ms23756 KiB
#include<bits/stdc++.h> using namespace std; typedef long long ll; #define x first #define y second ll n,m; vector<vector<pair<ll,ll>>> cad; vector<pair<ll,ll>> Dijkstra(ll ini) { vector<pair<ll,ll>> v(n+2, {1e16,1e16}); priority_queue<pair<ll,pair<ll,ll>>>q; q.push({0,{ini,-1}}); while(!q.empty()) { pair<ll,pair<ll,ll>> a=q.top();q.pop(); if(v[a.y.x].x==1e16) { v[a.y.x]={-a.x,a.y.y}; for(auto i:cad[a.y.x]) if(v[i.x].x==1e16) q.push({a.x-i.y,{i.x,a.y.x}}); } } return v; }; int main() { ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0); cin>>n>>m; ll s,t,l,k; cin>>s>>t>>l>>k; cad.resize(n+1); for(int i=0; i<m; i++) { ll a,b,c; cin>>a>>b>>c; cad[a].push_back({b,c}); cad[b].push_back({a,c}); } vector<pair<ll,ll>> vs=Dijkstra(s); vector<pair<ll,ll>> vt=Dijkstra(t); if(vs[t].x<=k) { cout<<n*(n-1)/2; return 0; } ll p=0;ll cont=0; sort(vs.begin(),vs.end()); sort(vt.begin(),vt.end()); for(int i=0; i<=n; i++) { ll j=n; while(j>=0&&vs[i].x+vt[j].x+l>k) j--; cont+=(j+1); } cout<<cont; return 0; }

Compilation message (stderr)

Main.cpp: In function 'int main()':
Main.cpp:48:8: warning: unused variable 'p' [-Wunused-variable]
   48 |     ll p=0;ll cont=0;
      |        ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...