Submission #1025386

# Submission time Handle Problem Language Result Execution time Memory
1025386 2024-07-17T01:23:18 Z ReLice Reconstruction Project (JOI22_reconstruction) C++17
0 / 100
4 ms 6492 KB
#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



*/

Compilation message

reconstruction.cpp: In function 'void solve()':
reconstruction.cpp:66:10: warning: unused variable 'j' [-Wunused-variable]
   66 |     ll i,j;
      |          ^
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 6492 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 6488 KB Output isn't correct
2 Halted 0 ms 0 KB -