#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
{
sort(b+1,b+1+n);
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);
}
cout<<s5;
}
}
Compilation message
Main.cpp:67:1: warning: ISO C++ forbids declaration of 'main' with no type [-Wreturn-type]
67 | main()
| ^~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
3 ms |
5468 KB |
Output is correct |
6 |
Correct |
3 ms |
5468 KB |
Output is correct |
7 |
Correct |
50 ms |
21416 KB |
Output is correct |
8 |
Correct |
63 ms |
21412 KB |
Output is correct |
9 |
Correct |
65 ms |
24540 KB |
Output is correct |
10 |
Correct |
4 ms |
4956 KB |
Output is correct |
11 |
Correct |
2 ms |
4956 KB |
Output is correct |
12 |
Correct |
3 ms |
5212 KB |
Output is correct |
13 |
Correct |
3 ms |
5212 KB |
Output is correct |
14 |
Correct |
32 ms |
15192 KB |
Output is correct |
15 |
Correct |
132 ms |
23148 KB |
Output is correct |
16 |
Correct |
3 ms |
4952 KB |
Output is correct |
17 |
Correct |
3 ms |
5212 KB |
Output is correct |
18 |
Correct |
61 ms |
20324 KB |
Output is correct |
19 |
Correct |
2 ms |
4952 KB |
Output is correct |
20 |
Correct |
2 ms |
4956 KB |
Output is correct |
21 |
Correct |
3 ms |
5212 KB |
Output is correct |
22 |
Correct |
4 ms |
5212 KB |
Output is correct |
23 |
Correct |
37 ms |
14884 KB |
Output is correct |
24 |
Correct |
124 ms |
23152 KB |
Output is correct |
25 |
Correct |
3 ms |
4956 KB |
Output is correct |
26 |
Correct |
3 ms |
5468 KB |
Output is correct |
27 |
Correct |
69 ms |
27720 KB |
Output is correct |
28 |
Correct |
63 ms |
20376 KB |
Output is correct |
29 |
Correct |
54 ms |
18256 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4952 KB |
Output is correct |
2 |
Correct |
3 ms |
4952 KB |
Output is correct |
3 |
Correct |
3 ms |
4956 KB |
Output is correct |
4 |
Correct |
3 ms |
4956 KB |
Output is correct |
5 |
Correct |
2 ms |
4956 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
3 ms |
4956 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
3 ms |
4956 KB |
Output is correct |
11 |
Correct |
3 ms |
4956 KB |
Output is correct |
12 |
Correct |
3 ms |
5132 KB |
Output is correct |
13 |
Correct |
3 ms |
4956 KB |
Output is correct |
14 |
Correct |
2 ms |
4956 KB |
Output is correct |
15 |
Correct |
3 ms |
4952 KB |
Output is correct |
16 |
Correct |
2 ms |
4956 KB |
Output is correct |
17 |
Correct |
2 ms |
4952 KB |
Output is correct |
18 |
Correct |
2 ms |
4956 KB |
Output is correct |
19 |
Correct |
2 ms |
4956 KB |
Output is correct |
20 |
Correct |
2 ms |
4956 KB |
Output is correct |
21 |
Correct |
2 ms |
4956 KB |
Output is correct |
22 |
Correct |
2 ms |
4956 KB |
Output is correct |
23 |
Correct |
4 ms |
4956 KB |
Output is correct |
24 |
Correct |
3 ms |
5164 KB |
Output is correct |
25 |
Correct |
3 ms |
4956 KB |
Output is correct |
26 |
Correct |
2 ms |
4956 KB |
Output is correct |
27 |
Correct |
2 ms |
4956 KB |
Output is correct |
28 |
Correct |
2 ms |
4956 KB |
Output is correct |
29 |
Correct |
3 ms |
4956 KB |
Output is correct |
30 |
Correct |
2 ms |
4956 KB |
Output is correct |
31 |
Correct |
3 ms |
4952 KB |
Output is correct |
32 |
Correct |
3 ms |
4952 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
4 ms |
4952 KB |
Output is correct |
2 |
Correct |
3 ms |
4952 KB |
Output is correct |
3 |
Correct |
3 ms |
4956 KB |
Output is correct |
4 |
Correct |
3 ms |
4956 KB |
Output is correct |
5 |
Correct |
2 ms |
4956 KB |
Output is correct |
6 |
Correct |
2 ms |
4956 KB |
Output is correct |
7 |
Correct |
2 ms |
4956 KB |
Output is correct |
8 |
Correct |
3 ms |
4956 KB |
Output is correct |
9 |
Correct |
2 ms |
4956 KB |
Output is correct |
10 |
Correct |
3 ms |
4956 KB |
Output is correct |
11 |
Correct |
3 ms |
4956 KB |
Output is correct |
12 |
Correct |
3 ms |
5132 KB |
Output is correct |
13 |
Correct |
3 ms |
4956 KB |
Output is correct |
14 |
Correct |
2 ms |
4956 KB |
Output is correct |
15 |
Correct |
3 ms |
4952 KB |
Output is correct |
16 |
Correct |
2 ms |
4956 KB |
Output is correct |
17 |
Correct |
2 ms |
4952 KB |
Output is correct |
18 |
Correct |
2 ms |
4956 KB |
Output is correct |
19 |
Correct |
2 ms |
4956 KB |
Output is correct |
20 |
Correct |
2 ms |
4956 KB |
Output is correct |
21 |
Correct |
2 ms |
4956 KB |
Output is correct |
22 |
Correct |
2 ms |
4956 KB |
Output is correct |
23 |
Correct |
4 ms |
4956 KB |
Output is correct |
24 |
Correct |
3 ms |
5164 KB |
Output is correct |
25 |
Correct |
3 ms |
4956 KB |
Output is correct |
26 |
Correct |
2 ms |
4956 KB |
Output is correct |
27 |
Correct |
2 ms |
4956 KB |
Output is correct |
28 |
Correct |
2 ms |
4956 KB |
Output is correct |
29 |
Correct |
3 ms |
4956 KB |
Output is correct |
30 |
Correct |
2 ms |
4956 KB |
Output is correct |
31 |
Correct |
3 ms |
4952 KB |
Output is correct |
32 |
Correct |
3 ms |
4952 KB |
Output is correct |
33 |
Correct |
3 ms |
5212 KB |
Output is correct |
34 |
Correct |
3 ms |
5432 KB |
Output is correct |
35 |
Correct |
3 ms |
5212 KB |
Output is correct |
36 |
Correct |
3 ms |
5212 KB |
Output is correct |
37 |
Correct |
3 ms |
5212 KB |
Output is correct |
38 |
Correct |
3 ms |
5176 KB |
Output is correct |
39 |
Correct |
4 ms |
5208 KB |
Output is correct |
40 |
Correct |
3 ms |
5468 KB |
Output is correct |
41 |
Correct |
5 ms |
5468 KB |
Output is correct |
42 |
Correct |
3 ms |
5248 KB |
Output is correct |
43 |
Correct |
4 ms |
5464 KB |
Output is correct |
44 |
Correct |
4 ms |
5212 KB |
Output is correct |
45 |
Correct |
3 ms |
5212 KB |
Output is correct |
46 |
Correct |
4 ms |
5212 KB |
Output is correct |
47 |
Correct |
3 ms |
5212 KB |
Output is correct |
48 |
Correct |
3 ms |
5212 KB |
Output is correct |
49 |
Correct |
4 ms |
5464 KB |
Output is correct |
50 |
Correct |
3 ms |
5212 KB |
Output is correct |
51 |
Correct |
4 ms |
5468 KB |
Output is correct |
52 |
Correct |
3 ms |
5468 KB |
Output is correct |
53 |
Correct |
5 ms |
5468 KB |
Output is correct |
54 |
Correct |
5 ms |
5468 KB |
Output is correct |
55 |
Correct |
4 ms |
5420 KB |
Output is correct |
56 |
Correct |
3 ms |
5468 KB |
Output is correct |
57 |
Correct |
3 ms |
5212 KB |
Output is correct |
58 |
Correct |
3 ms |
5212 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
4956 KB |
Output is correct |
2 |
Correct |
2 ms |
4956 KB |
Output is correct |
3 |
Correct |
2 ms |
4956 KB |
Output is correct |
4 |
Correct |
2 ms |
4956 KB |
Output is correct |
5 |
Correct |
3 ms |
5468 KB |
Output is correct |
6 |
Correct |
3 ms |
5468 KB |
Output is correct |
7 |
Correct |
50 ms |
21416 KB |
Output is correct |
8 |
Correct |
63 ms |
21412 KB |
Output is correct |
9 |
Correct |
65 ms |
24540 KB |
Output is correct |
10 |
Correct |
4 ms |
4956 KB |
Output is correct |
11 |
Correct |
2 ms |
4956 KB |
Output is correct |
12 |
Correct |
3 ms |
5212 KB |
Output is correct |
13 |
Correct |
3 ms |
5212 KB |
Output is correct |
14 |
Correct |
32 ms |
15192 KB |
Output is correct |
15 |
Correct |
132 ms |
23148 KB |
Output is correct |
16 |
Correct |
3 ms |
4952 KB |
Output is correct |
17 |
Correct |
3 ms |
5212 KB |
Output is correct |
18 |
Correct |
61 ms |
20324 KB |
Output is correct |
19 |
Correct |
2 ms |
4952 KB |
Output is correct |
20 |
Correct |
2 ms |
4956 KB |
Output is correct |
21 |
Correct |
3 ms |
5212 KB |
Output is correct |
22 |
Correct |
4 ms |
5212 KB |
Output is correct |
23 |
Correct |
37 ms |
14884 KB |
Output is correct |
24 |
Correct |
124 ms |
23152 KB |
Output is correct |
25 |
Correct |
3 ms |
4956 KB |
Output is correct |
26 |
Correct |
3 ms |
5468 KB |
Output is correct |
27 |
Correct |
69 ms |
27720 KB |
Output is correct |
28 |
Correct |
63 ms |
20376 KB |
Output is correct |
29 |
Correct |
54 ms |
18256 KB |
Output is correct |
30 |
Correct |
4 ms |
4952 KB |
Output is correct |
31 |
Correct |
3 ms |
4952 KB |
Output is correct |
32 |
Correct |
3 ms |
4956 KB |
Output is correct |
33 |
Correct |
3 ms |
4956 KB |
Output is correct |
34 |
Correct |
2 ms |
4956 KB |
Output is correct |
35 |
Correct |
2 ms |
4956 KB |
Output is correct |
36 |
Correct |
2 ms |
4956 KB |
Output is correct |
37 |
Correct |
3 ms |
4956 KB |
Output is correct |
38 |
Correct |
2 ms |
4956 KB |
Output is correct |
39 |
Correct |
3 ms |
4956 KB |
Output is correct |
40 |
Correct |
3 ms |
4956 KB |
Output is correct |
41 |
Correct |
3 ms |
5132 KB |
Output is correct |
42 |
Correct |
3 ms |
4956 KB |
Output is correct |
43 |
Correct |
2 ms |
4956 KB |
Output is correct |
44 |
Correct |
3 ms |
4952 KB |
Output is correct |
45 |
Correct |
2 ms |
4956 KB |
Output is correct |
46 |
Correct |
2 ms |
4952 KB |
Output is correct |
47 |
Correct |
2 ms |
4956 KB |
Output is correct |
48 |
Correct |
2 ms |
4956 KB |
Output is correct |
49 |
Correct |
2 ms |
4956 KB |
Output is correct |
50 |
Correct |
2 ms |
4956 KB |
Output is correct |
51 |
Correct |
2 ms |
4956 KB |
Output is correct |
52 |
Correct |
4 ms |
4956 KB |
Output is correct |
53 |
Correct |
3 ms |
5164 KB |
Output is correct |
54 |
Correct |
3 ms |
4956 KB |
Output is correct |
55 |
Correct |
2 ms |
4956 KB |
Output is correct |
56 |
Correct |
2 ms |
4956 KB |
Output is correct |
57 |
Correct |
2 ms |
4956 KB |
Output is correct |
58 |
Correct |
3 ms |
4956 KB |
Output is correct |
59 |
Correct |
2 ms |
4956 KB |
Output is correct |
60 |
Correct |
3 ms |
4952 KB |
Output is correct |
61 |
Correct |
3 ms |
4952 KB |
Output is correct |
62 |
Correct |
3 ms |
5212 KB |
Output is correct |
63 |
Correct |
3 ms |
5432 KB |
Output is correct |
64 |
Correct |
3 ms |
5212 KB |
Output is correct |
65 |
Correct |
3 ms |
5212 KB |
Output is correct |
66 |
Correct |
3 ms |
5212 KB |
Output is correct |
67 |
Correct |
3 ms |
5176 KB |
Output is correct |
68 |
Correct |
4 ms |
5208 KB |
Output is correct |
69 |
Correct |
3 ms |
5468 KB |
Output is correct |
70 |
Correct |
5 ms |
5468 KB |
Output is correct |
71 |
Correct |
3 ms |
5248 KB |
Output is correct |
72 |
Correct |
4 ms |
5464 KB |
Output is correct |
73 |
Correct |
4 ms |
5212 KB |
Output is correct |
74 |
Correct |
3 ms |
5212 KB |
Output is correct |
75 |
Correct |
4 ms |
5212 KB |
Output is correct |
76 |
Correct |
3 ms |
5212 KB |
Output is correct |
77 |
Correct |
3 ms |
5212 KB |
Output is correct |
78 |
Correct |
4 ms |
5464 KB |
Output is correct |
79 |
Correct |
3 ms |
5212 KB |
Output is correct |
80 |
Correct |
4 ms |
5468 KB |
Output is correct |
81 |
Correct |
3 ms |
5468 KB |
Output is correct |
82 |
Correct |
5 ms |
5468 KB |
Output is correct |
83 |
Correct |
5 ms |
5468 KB |
Output is correct |
84 |
Correct |
4 ms |
5420 KB |
Output is correct |
85 |
Correct |
3 ms |
5468 KB |
Output is correct |
86 |
Correct |
3 ms |
5212 KB |
Output is correct |
87 |
Correct |
3 ms |
5212 KB |
Output is correct |
88 |
Correct |
100 ms |
23808 KB |
Output is correct |
89 |
Correct |
87 ms |
23740 KB |
Output is correct |
90 |
Incorrect |
91 ms |
23632 KB |
Output isn't correct |
91 |
Halted |
0 ms |
0 KB |
- |