제출 #1025388

#제출 시각아이디문제언어결과실행 시간메모리
1025388ReLiceConstruction Project 2 (JOI24_ho_t2)C++17
53 / 100
2062 ms37052 KiB
#include <bits/stdc++.h> #define ll long long #define str string #define ins insert #define ld long double #define pb push_back #define pf push_front #define pof pop_front() #define pob pop_back() #define lb lower_bound #define ub upper_bound #define endl "\n" #define fr first #define sc second #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #define sz size() #define vll vector<ll> #define bc back() #define arr array #define pll vector<pair<ll,ll>> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; #define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> template<class S,class T> bool chmin(S &a,const T &b) { return a>b?(a=b)==b:false; } template<class S,class T> bool chmax(S &a,const T &b) { return a<b?(a=b)==b:false; } //void fre(string s){freopen((s+".in").c_str(),"r",stdin);freopen((s+".out").c_str(),"w",stdout);} void start(){ ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); } const ll inf=1e18; const ll mod=1e18+7; const ll mod2=1e9+11; const ll N=2e5+7; const ld eps=1e-9; vector<pll> g(N); ll d[N]; void dijkstra(ll s){ set<pair<ll,ll>> st; memset(d,0x3f,sizeof(d)); d[s]=0; st.ins({d[s],s}); while(st.sz){ ll x=st.begin()->sc; st.erase(st.begin()); for(auto i : g[x]){ ll to=i.fr,len=i.sc; if(d[to]>d[x]+len){ d[to]=d[x]+len; st.ins({d[to],to}); } } } } void solve(){ ll i,j; ll n,m; ll s,t,l,k; cin>>n>>m; cin>>s>>t>>l>>k; for(i=0;i<m;i++){ ll a,b,c; cin>>a>>b>>c; g[a].pb({b,c}); g[b].pb({a,c}); } dijkstra(s); pll vs; for(i=1;i<=n;i++)vs.pb({d[i],i}); dijkstra(t); ll ans=0; vll vt; for(i=1;i<=n;i++)vt.pb(d[i]); sort(all(vt)); if(d[s]<=k){ cout<<n*(n-1)/2<<endl; return; } for(i=0;i<n;i++){ ans+=lb(all(vt),k-l-vs[i].fr+1)-vt.begin(); } cout<<ans<<endl; } signed main(){ start(); ll t=1; //cin>>t; while(t--) solve(); return 0; } /* a<b<c<d a a b b a a a a */

컴파일 시 표준 에러 (stderr) 메시지

Main.cpp: In function 'void solve()':
Main.cpp:66:10: warning: unused variable 'j' [-Wunused-variable]
   66 |     ll i,j;
      |          ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...