답안 #1025389

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1025389 2024-07-17T01:25:15 Z ReLice Construction Project 2 (JOI24_ho_t2) C++17
100 / 100
238 ms 32700 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,dd=st.begin()->fr;
        st.erase(st.begin());
        if(dd!=d[x])continue;
        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

Main.cpp: In function 'void solve()':
Main.cpp:67:10: warning: unused variable 'j' [-Wunused-variable]
   67 |     ll i,j;
      |          ^
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6748 KB Output is correct
2 Correct 3 ms 6652 KB Output is correct
3 Correct 3 ms 6492 KB Output is correct
4 Correct 3 ms 6492 KB Output is correct
5 Correct 4 ms 6748 KB Output is correct
6 Correct 4 ms 7004 KB Output is correct
7 Correct 70 ms 22324 KB Output is correct
8 Correct 92 ms 22324 KB Output is correct
9 Correct 92 ms 24924 KB Output is correct
10 Correct 3 ms 6488 KB Output is correct
11 Correct 4 ms 6492 KB Output is correct
12 Correct 3 ms 6748 KB Output is correct
13 Correct 4 ms 6948 KB Output is correct
14 Correct 41 ms 18620 KB Output is correct
15 Correct 170 ms 24604 KB Output is correct
16 Correct 3 ms 6488 KB Output is correct
17 Correct 4 ms 7004 KB Output is correct
18 Correct 72 ms 22720 KB Output is correct
19 Correct 3 ms 6492 KB Output is correct
20 Correct 3 ms 6632 KB Output is correct
21 Correct 3 ms 6720 KB Output is correct
22 Correct 4 ms 7004 KB Output is correct
23 Correct 40 ms 18648 KB Output is correct
24 Correct 167 ms 24716 KB Output is correct
25 Correct 3 ms 6492 KB Output is correct
26 Correct 4 ms 7004 KB Output is correct
27 Correct 120 ms 32700 KB Output is correct
28 Correct 79 ms 22840 KB Output is correct
29 Correct 60 ms 20168 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 3 ms 6492 KB Output is correct
3 Correct 3 ms 6492 KB Output is correct
4 Correct 3 ms 6492 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 3 ms 6664 KB Output is correct
7 Correct 3 ms 6492 KB Output is correct
8 Correct 3 ms 6492 KB Output is correct
9 Correct 3 ms 6492 KB Output is correct
10 Correct 3 ms 6492 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 3 ms 6704 KB Output is correct
14 Correct 3 ms 6492 KB Output is correct
15 Correct 3 ms 6492 KB Output is correct
16 Correct 3 ms 6492 KB Output is correct
17 Correct 3 ms 6492 KB Output is correct
18 Correct 3 ms 6492 KB Output is correct
19 Correct 3 ms 6488 KB Output is correct
20 Correct 4 ms 6492 KB Output is correct
21 Correct 3 ms 6492 KB Output is correct
22 Correct 3 ms 6492 KB Output is correct
23 Correct 3 ms 6492 KB Output is correct
24 Correct 3 ms 6492 KB Output is correct
25 Correct 3 ms 6492 KB Output is correct
26 Correct 3 ms 6484 KB Output is correct
27 Correct 3 ms 6492 KB Output is correct
28 Correct 3 ms 6492 KB Output is correct
29 Correct 3 ms 6492 KB Output is correct
30 Correct 3 ms 6492 KB Output is correct
31 Correct 3 ms 6492 KB Output is correct
32 Correct 3 ms 6492 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 6492 KB Output is correct
2 Correct 3 ms 6492 KB Output is correct
3 Correct 3 ms 6492 KB Output is correct
4 Correct 3 ms 6492 KB Output is correct
5 Correct 3 ms 6492 KB Output is correct
6 Correct 3 ms 6664 KB Output is correct
7 Correct 3 ms 6492 KB Output is correct
8 Correct 3 ms 6492 KB Output is correct
9 Correct 3 ms 6492 KB Output is correct
10 Correct 3 ms 6492 KB Output is correct
11 Correct 3 ms 6492 KB Output is correct
12 Correct 3 ms 6492 KB Output is correct
13 Correct 3 ms 6704 KB Output is correct
14 Correct 3 ms 6492 KB Output is correct
15 Correct 3 ms 6492 KB Output is correct
16 Correct 3 ms 6492 KB Output is correct
17 Correct 3 ms 6492 KB Output is correct
18 Correct 3 ms 6492 KB Output is correct
19 Correct 3 ms 6488 KB Output is correct
20 Correct 4 ms 6492 KB Output is correct
21 Correct 3 ms 6492 KB Output is correct
22 Correct 3 ms 6492 KB Output is correct
23 Correct 3 ms 6492 KB Output is correct
24 Correct 3 ms 6492 KB Output is correct
25 Correct 3 ms 6492 KB Output is correct
26 Correct 3 ms 6484 KB Output is correct
27 Correct 3 ms 6492 KB Output is correct
28 Correct 3 ms 6492 KB Output is correct
29 Correct 3 ms 6492 KB Output is correct
30 Correct 3 ms 6492 KB Output is correct
31 Correct 3 ms 6492 KB Output is correct
32 Correct 3 ms 6492 KB Output is correct
33 Correct 3 ms 6744 KB Output is correct
34 Correct 4 ms 7000 KB Output is correct
35 Correct 4 ms 6788 KB Output is correct
36 Correct 5 ms 7004 KB Output is correct
37 Correct 4 ms 7000 KB Output is correct
38 Correct 3 ms 6892 KB Output is correct
39 Correct 4 ms 7004 KB Output is correct
40 Correct 4 ms 7004 KB Output is correct
41 Correct 3 ms 6744 KB Output is correct
42 Correct 3 ms 6748 KB Output is correct
43 Correct 5 ms 6824 KB Output is correct
44 Correct 4 ms 7004 KB Output is correct
45 Correct 5 ms 7004 KB Output is correct
46 Correct 4 ms 7004 KB Output is correct
47 Correct 4 ms 7004 KB Output is correct
48 Correct 4 ms 6988 KB Output is correct
49 Correct 4 ms 6748 KB Output is correct
50 Correct 3 ms 6748 KB Output is correct
51 Correct 4 ms 7004 KB Output is correct
52 Correct 4 ms 7004 KB Output is correct
53 Correct 4 ms 7004 KB Output is correct
54 Correct 5 ms 7008 KB Output is correct
55 Correct 4 ms 6748 KB Output is correct
56 Correct 4 ms 6748 KB Output is correct
57 Correct 4 ms 6752 KB Output is correct
58 Correct 4 ms 6828 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 6748 KB Output is correct
2 Correct 3 ms 6652 KB Output is correct
3 Correct 3 ms 6492 KB Output is correct
4 Correct 3 ms 6492 KB Output is correct
5 Correct 4 ms 6748 KB Output is correct
6 Correct 4 ms 7004 KB Output is correct
7 Correct 70 ms 22324 KB Output is correct
8 Correct 92 ms 22324 KB Output is correct
9 Correct 92 ms 24924 KB Output is correct
10 Correct 3 ms 6488 KB Output is correct
11 Correct 4 ms 6492 KB Output is correct
12 Correct 3 ms 6748 KB Output is correct
13 Correct 4 ms 6948 KB Output is correct
14 Correct 41 ms 18620 KB Output is correct
15 Correct 170 ms 24604 KB Output is correct
16 Correct 3 ms 6488 KB Output is correct
17 Correct 4 ms 7004 KB Output is correct
18 Correct 72 ms 22720 KB Output is correct
19 Correct 3 ms 6492 KB Output is correct
20 Correct 3 ms 6632 KB Output is correct
21 Correct 3 ms 6720 KB Output is correct
22 Correct 4 ms 7004 KB Output is correct
23 Correct 40 ms 18648 KB Output is correct
24 Correct 167 ms 24716 KB Output is correct
25 Correct 3 ms 6492 KB Output is correct
26 Correct 4 ms 7004 KB Output is correct
27 Correct 120 ms 32700 KB Output is correct
28 Correct 79 ms 22840 KB Output is correct
29 Correct 60 ms 20168 KB Output is correct
30 Correct 3 ms 6492 KB Output is correct
31 Correct 3 ms 6492 KB Output is correct
32 Correct 3 ms 6492 KB Output is correct
33 Correct 3 ms 6492 KB Output is correct
34 Correct 3 ms 6492 KB Output is correct
35 Correct 3 ms 6664 KB Output is correct
36 Correct 3 ms 6492 KB Output is correct
37 Correct 3 ms 6492 KB Output is correct
38 Correct 3 ms 6492 KB Output is correct
39 Correct 3 ms 6492 KB Output is correct
40 Correct 3 ms 6492 KB Output is correct
41 Correct 3 ms 6492 KB Output is correct
42 Correct 3 ms 6704 KB Output is correct
43 Correct 3 ms 6492 KB Output is correct
44 Correct 3 ms 6492 KB Output is correct
45 Correct 3 ms 6492 KB Output is correct
46 Correct 3 ms 6492 KB Output is correct
47 Correct 3 ms 6492 KB Output is correct
48 Correct 3 ms 6488 KB Output is correct
49 Correct 4 ms 6492 KB Output is correct
50 Correct 3 ms 6492 KB Output is correct
51 Correct 3 ms 6492 KB Output is correct
52 Correct 3 ms 6492 KB Output is correct
53 Correct 3 ms 6492 KB Output is correct
54 Correct 3 ms 6492 KB Output is correct
55 Correct 3 ms 6484 KB Output is correct
56 Correct 3 ms 6492 KB Output is correct
57 Correct 3 ms 6492 KB Output is correct
58 Correct 3 ms 6492 KB Output is correct
59 Correct 3 ms 6492 KB Output is correct
60 Correct 3 ms 6492 KB Output is correct
61 Correct 3 ms 6492 KB Output is correct
62 Correct 3 ms 6744 KB Output is correct
63 Correct 4 ms 7000 KB Output is correct
64 Correct 4 ms 6788 KB Output is correct
65 Correct 5 ms 7004 KB Output is correct
66 Correct 4 ms 7000 KB Output is correct
67 Correct 3 ms 6892 KB Output is correct
68 Correct 4 ms 7004 KB Output is correct
69 Correct 4 ms 7004 KB Output is correct
70 Correct 3 ms 6744 KB Output is correct
71 Correct 3 ms 6748 KB Output is correct
72 Correct 5 ms 6824 KB Output is correct
73 Correct 4 ms 7004 KB Output is correct
74 Correct 5 ms 7004 KB Output is correct
75 Correct 4 ms 7004 KB Output is correct
76 Correct 4 ms 7004 KB Output is correct
77 Correct 4 ms 6988 KB Output is correct
78 Correct 4 ms 6748 KB Output is correct
79 Correct 3 ms 6748 KB Output is correct
80 Correct 4 ms 7004 KB Output is correct
81 Correct 4 ms 7004 KB Output is correct
82 Correct 4 ms 7004 KB Output is correct
83 Correct 5 ms 7008 KB Output is correct
84 Correct 4 ms 6748 KB Output is correct
85 Correct 4 ms 6748 KB Output is correct
86 Correct 4 ms 6752 KB Output is correct
87 Correct 4 ms 6828 KB Output is correct
88 Correct 112 ms 24184 KB Output is correct
89 Correct 105 ms 24128 KB Output is correct
90 Correct 95 ms 24012 KB Output is correct
91 Correct 39 ms 16756 KB Output is correct
92 Correct 39 ms 16976 KB Output is correct
93 Correct 62 ms 18576 KB Output is correct
94 Correct 44 ms 18620 KB Output is correct
95 Correct 204 ms 25416 KB Output is correct
96 Correct 196 ms 24908 KB Output is correct
97 Correct 174 ms 23880 KB Output is correct
98 Correct 149 ms 23740 KB Output is correct
99 Correct 67 ms 22772 KB Output is correct
100 Correct 70 ms 22836 KB Output is correct
101 Correct 39 ms 16976 KB Output is correct
102 Correct 45 ms 16904 KB Output is correct
103 Correct 45 ms 18620 KB Output is correct
104 Correct 52 ms 18624 KB Output is correct
105 Correct 211 ms 25412 KB Output is correct
106 Correct 238 ms 24664 KB Output is correct
107 Correct 226 ms 32696 KB Output is correct
108 Correct 224 ms 32700 KB Output is correct
109 Correct 92 ms 22660 KB Output is correct
110 Correct 109 ms 26412 KB Output is correct
111 Correct 99 ms 24112 KB Output is correct
112 Correct 84 ms 24140 KB Output is correct