This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#pragma GCC optimize("Ofast,unroll-loops")
#include<bits/stdc++.h>
#define int long long
//#define ll long long
#define down cout<<'\n';
#define debug cout<<" cucuucucuuu",down
#define NHP ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);
#define modwwe int t;cin>>t; while(t--)
#define bit(i,j) (i>>j&1)
#define sobit(a) __builtin_popcountll(a)
#define task "test"
#define fin(x) freopen(x".inp","r",stdin)
#define fou(x) freopen(x".out","w",stdout)
#define pb push_back
#define checktime cerr << (double)clock() / CLOCKS_PER_SEC * 1000 << " ms";
using namespace std;
#define getchar_unlocked getchar
inline int scan()
{
char c = getchar_unlocked();
int x = 0;
while (c < '0' || c > '9')
{
c = getchar_unlocked();
}
while (c >= '0' && c <= '9')
{
x = (x << 1) + (x << 3) + c - '0';
c = getchar_unlocked();
}
return x;
}
void phongbeo();
const int inf = 1e15;
const int mod2 = 1e9 + 9;
const int mod1 = 998244353;
struct icd
{
long double a;
int b;
};
struct ib
{
int a;
int b;
};
struct ic
{
int a, b, c;
};
struct id
{
int a, b, c, d;
};
struct ie
{
int a, b, c, d, e;
};
int n, m, s1, s2, s4, s3, sf, k, s5, s6, mx, s7, s8, s9, mx2, res, dem2 = 0, dem = 0, s33, dem3, dem4, l, r, mid, l2, r2, center;
int i, s10, s12,k1,k2,s11;
int kk;
int el = 19;
main()
{
fin(task);
fou(task);
NHP
/// cin>>s1;
///modwwe
phongbeo();
// checktime
}
int s,t;
int a[200001];
int b[200001];
vector<ib> v[200001];
struct cmp
{
bool operator()(ib a,ib b)
{
return a.b>b.b;
}
};
void dist(int x,int c[])
{
priority_queue<ib,vector<ib>,cmp>p;
p.push({x,0});
while(!p.empty())
{
ib x=p.top();
p.pop();
if(c[x.a]!=-1) continue;
c[x.a]=x.b;
for(auto f:v[x.a])
if(c[f.a]==-1)
p.push({f.a,f.b+x.b});
}
}
void phongbeo()
{
cin>>n>>m;
cin>>s>>t>>l>>k;
for(int i=1; i<=m; i++)
cin>>s2>>s3>>s4,v[s2].pb({s3,s4}),v[s3].pb({s2,s4});
for(int i=1; i<=n; i++)
a[i]=-1,b[i]=-1;
dist(s,a);
dist(t,b);
for(int i=1; i<=n; i++)
{
if(a[i]==-1)
a[i]=inf;
if(b[i]==-1) b[i]=inf;
}
if(a[t]<=k)
{
cout<<n*(n-1)/2;
}
else
{
for(int i=1; i<=n; i++)
{
if(a[i]==inf) continue;
s3=k-a[i]-l;
s4=upper_bound(b,b+1+n,s3)-b-1;
s5=s5+max(0ll,s4-2);
}
sort(b+1,b+1+n);
cout<<s5;
}
}
Compilation message (stderr)
Main.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
67 | main()
| ^~~~
Main.cpp: In function 'int main()':
Main.cpp:12:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
12 | #define fin(x) freopen(x".inp","r",stdin)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~
Main.cpp:69:5: note: in expansion of macro 'fin'
69 | fin(task);
| ^~~
Main.cpp:13:23: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
13 | #define fou(x) freopen(x".out","w",stdout)
| ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:70:5: note: in expansion of macro 'fou'
70 | fou(task);
| ^~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |