답안 #1013913

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1013913 2024-07-04T08:04:28 Z Baytoro Construction Project 2 (JOI24_ho_t2) C++17
100 / 100
506 ms 48188 KB
#include <bits/stdc++.h>


#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define orderedset tree<long long, null_type, less_equal<long long>, rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
#define ll long long
#define pb push_back
#define fr first
#define sc second
#define int ll
#define all(x) x.begin(),x.end()
const int N=2e5+5;
vector<pair<int,int>> g[N];
vector<int> dist1,dist2;
void djks(int x, int c) {
    vector<int> dist(N,1e18);

    priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
    pq.push({0,x});
    dist[x]=0;
    while(!pq.empty()) {
        int k=pq.top().sc;
        int d=pq.top().fr;
        pq.pop();
        if(dist[k]!=d) continue;
        for(auto it: g[k]) {
            if(dist[it.fr]>d+it.sc) {
                dist[it.fr]=d+it.sc;
                pq.push({dist[it.fr],it.fr});
            }
        }
    }
    if(c==0) dist1=dist;
    else dist2=dist;
}
void solve(){
    int n,m;cin>>n>>m;
    int s,t,l,k;cin>>s>>t>>l>>k;
    for(int i=0;i<m;i++) {
        int a,b,c;cin>>a>>b>>c;
        g[a].pb({b,c});
        g[b].pb({a,c});
    }
    djks(s,0);
    djks(t,1);
    if(dist1[t]<=k) {
        cout<<n*(n-1)/2;
        return;
    }
    int ans=0;
    orderedset a,b;
    a.insert(1e18);
    b.insert(1e18);
    for(int i=1;i<=n;i++){
        int A=a.order_of_key(k-(dist1[i]+l)+1);
        int B=b.order_of_key(k-(dist2[i]+l)+1);
        //cout<<A<<' '<<B<<endl;
        ans+=A;
        ans+=B;
        a.insert(dist2[i]);
        b.insert(dist1[i]);
    }
    cout<<ans<<endl;
}
signed main(){
    int t=1;//cin>>t;
    while(t--){
        solve();
    }
}
//#endif
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9788 KB Output is correct
2 Correct 4 ms 9792 KB Output is correct
3 Correct 5 ms 9792 KB Output is correct
4 Correct 5 ms 9792 KB Output is correct
5 Correct 6 ms 9820 KB Output is correct
6 Correct 6 ms 9984 KB Output is correct
7 Correct 224 ms 43160 KB Output is correct
8 Correct 244 ms 43024 KB Output is correct
9 Correct 106 ms 21944 KB Output is correct
10 Correct 5 ms 9788 KB Output is correct
11 Correct 5 ms 9792 KB Output is correct
12 Correct 6 ms 9840 KB Output is correct
13 Correct 7 ms 10000 KB Output is correct
14 Correct 304 ms 39840 KB Output is correct
15 Correct 331 ms 46536 KB Output is correct
16 Correct 4 ms 9788 KB Output is correct
17 Correct 7 ms 9792 KB Output is correct
18 Correct 333 ms 45368 KB Output is correct
19 Correct 4 ms 9788 KB Output is correct
20 Correct 4 ms 9712 KB Output is correct
21 Correct 6 ms 9792 KB Output is correct
22 Correct 8 ms 9864 KB Output is correct
23 Correct 309 ms 39980 KB Output is correct
24 Correct 345 ms 46388 KB Output is correct
25 Correct 4 ms 9788 KB Output is correct
26 Correct 6 ms 10076 KB Output is correct
27 Correct 135 ms 27704 KB Output is correct
28 Correct 219 ms 30836 KB Output is correct
29 Correct 217 ms 35896 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9788 KB Output is correct
2 Correct 4 ms 9792 KB Output is correct
3 Correct 4 ms 9788 KB Output is correct
4 Correct 5 ms 9792 KB Output is correct
5 Correct 4 ms 9708 KB Output is correct
6 Correct 5 ms 9792 KB Output is correct
7 Correct 4 ms 9792 KB Output is correct
8 Correct 4 ms 9712 KB Output is correct
9 Correct 4 ms 9792 KB Output is correct
10 Correct 5 ms 9676 KB Output is correct
11 Correct 4 ms 9792 KB Output is correct
12 Correct 4 ms 9792 KB Output is correct
13 Correct 4 ms 9792 KB Output is correct
14 Correct 4 ms 9792 KB Output is correct
15 Correct 4 ms 9792 KB Output is correct
16 Correct 4 ms 9788 KB Output is correct
17 Correct 5 ms 9788 KB Output is correct
18 Correct 4 ms 9792 KB Output is correct
19 Correct 5 ms 9788 KB Output is correct
20 Correct 5 ms 9712 KB Output is correct
21 Correct 4 ms 9792 KB Output is correct
22 Correct 5 ms 9724 KB Output is correct
23 Correct 4 ms 9788 KB Output is correct
24 Correct 5 ms 9792 KB Output is correct
25 Correct 4 ms 9624 KB Output is correct
26 Correct 4 ms 9792 KB Output is correct
27 Correct 4 ms 9716 KB Output is correct
28 Correct 7 ms 9792 KB Output is correct
29 Correct 4 ms 9828 KB Output is correct
30 Correct 4 ms 9792 KB Output is correct
31 Correct 5 ms 9788 KB Output is correct
32 Correct 4 ms 9748 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 4 ms 9788 KB Output is correct
2 Correct 4 ms 9792 KB Output is correct
3 Correct 4 ms 9788 KB Output is correct
4 Correct 5 ms 9792 KB Output is correct
5 Correct 4 ms 9708 KB Output is correct
6 Correct 5 ms 9792 KB Output is correct
7 Correct 4 ms 9792 KB Output is correct
8 Correct 4 ms 9712 KB Output is correct
9 Correct 4 ms 9792 KB Output is correct
10 Correct 5 ms 9676 KB Output is correct
11 Correct 4 ms 9792 KB Output is correct
12 Correct 4 ms 9792 KB Output is correct
13 Correct 4 ms 9792 KB Output is correct
14 Correct 4 ms 9792 KB Output is correct
15 Correct 4 ms 9792 KB Output is correct
16 Correct 4 ms 9788 KB Output is correct
17 Correct 5 ms 9788 KB Output is correct
18 Correct 4 ms 9792 KB Output is correct
19 Correct 5 ms 9788 KB Output is correct
20 Correct 5 ms 9712 KB Output is correct
21 Correct 4 ms 9792 KB Output is correct
22 Correct 5 ms 9724 KB Output is correct
23 Correct 4 ms 9788 KB Output is correct
24 Correct 5 ms 9792 KB Output is correct
25 Correct 4 ms 9624 KB Output is correct
26 Correct 4 ms 9792 KB Output is correct
27 Correct 4 ms 9716 KB Output is correct
28 Correct 7 ms 9792 KB Output is correct
29 Correct 4 ms 9828 KB Output is correct
30 Correct 4 ms 9792 KB Output is correct
31 Correct 5 ms 9788 KB Output is correct
32 Correct 4 ms 9748 KB Output is correct
33 Correct 6 ms 10048 KB Output is correct
34 Correct 6 ms 10044 KB Output is correct
35 Correct 6 ms 9792 KB Output is correct
36 Correct 7 ms 10048 KB Output is correct
37 Correct 7 ms 9792 KB Output is correct
38 Correct 10 ms 9792 KB Output is correct
39 Correct 7 ms 9988 KB Output is correct
40 Correct 6 ms 10044 KB Output is correct
41 Correct 6 ms 10300 KB Output is correct
42 Correct 7 ms 10044 KB Output is correct
43 Correct 8 ms 9928 KB Output is correct
44 Correct 7 ms 10048 KB Output is correct
45 Correct 8 ms 10300 KB Output is correct
46 Correct 9 ms 10048 KB Output is correct
47 Correct 12 ms 9984 KB Output is correct
48 Correct 8 ms 9792 KB Output is correct
49 Correct 6 ms 9968 KB Output is correct
50 Correct 6 ms 9820 KB Output is correct
51 Correct 8 ms 10048 KB Output is correct
52 Correct 7 ms 9980 KB Output is correct
53 Correct 8 ms 9984 KB Output is correct
54 Correct 8 ms 10048 KB Output is correct
55 Correct 6 ms 10048 KB Output is correct
56 Correct 7 ms 10044 KB Output is correct
57 Correct 9 ms 9804 KB Output is correct
58 Correct 6 ms 9984 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 9788 KB Output is correct
2 Correct 4 ms 9792 KB Output is correct
3 Correct 5 ms 9792 KB Output is correct
4 Correct 5 ms 9792 KB Output is correct
5 Correct 6 ms 9820 KB Output is correct
6 Correct 6 ms 9984 KB Output is correct
7 Correct 224 ms 43160 KB Output is correct
8 Correct 244 ms 43024 KB Output is correct
9 Correct 106 ms 21944 KB Output is correct
10 Correct 5 ms 9788 KB Output is correct
11 Correct 5 ms 9792 KB Output is correct
12 Correct 6 ms 9840 KB Output is correct
13 Correct 7 ms 10000 KB Output is correct
14 Correct 304 ms 39840 KB Output is correct
15 Correct 331 ms 46536 KB Output is correct
16 Correct 4 ms 9788 KB Output is correct
17 Correct 7 ms 9792 KB Output is correct
18 Correct 333 ms 45368 KB Output is correct
19 Correct 4 ms 9788 KB Output is correct
20 Correct 4 ms 9712 KB Output is correct
21 Correct 6 ms 9792 KB Output is correct
22 Correct 8 ms 9864 KB Output is correct
23 Correct 309 ms 39980 KB Output is correct
24 Correct 345 ms 46388 KB Output is correct
25 Correct 4 ms 9788 KB Output is correct
26 Correct 6 ms 10076 KB Output is correct
27 Correct 135 ms 27704 KB Output is correct
28 Correct 219 ms 30836 KB Output is correct
29 Correct 217 ms 35896 KB Output is correct
30 Correct 4 ms 9788 KB Output is correct
31 Correct 4 ms 9792 KB Output is correct
32 Correct 4 ms 9788 KB Output is correct
33 Correct 5 ms 9792 KB Output is correct
34 Correct 4 ms 9708 KB Output is correct
35 Correct 5 ms 9792 KB Output is correct
36 Correct 4 ms 9792 KB Output is correct
37 Correct 4 ms 9712 KB Output is correct
38 Correct 4 ms 9792 KB Output is correct
39 Correct 5 ms 9676 KB Output is correct
40 Correct 4 ms 9792 KB Output is correct
41 Correct 4 ms 9792 KB Output is correct
42 Correct 4 ms 9792 KB Output is correct
43 Correct 4 ms 9792 KB Output is correct
44 Correct 4 ms 9792 KB Output is correct
45 Correct 4 ms 9788 KB Output is correct
46 Correct 5 ms 9788 KB Output is correct
47 Correct 4 ms 9792 KB Output is correct
48 Correct 5 ms 9788 KB Output is correct
49 Correct 5 ms 9712 KB Output is correct
50 Correct 4 ms 9792 KB Output is correct
51 Correct 5 ms 9724 KB Output is correct
52 Correct 4 ms 9788 KB Output is correct
53 Correct 5 ms 9792 KB Output is correct
54 Correct 4 ms 9624 KB Output is correct
55 Correct 4 ms 9792 KB Output is correct
56 Correct 4 ms 9716 KB Output is correct
57 Correct 7 ms 9792 KB Output is correct
58 Correct 4 ms 9828 KB Output is correct
59 Correct 4 ms 9792 KB Output is correct
60 Correct 5 ms 9788 KB Output is correct
61 Correct 4 ms 9748 KB Output is correct
62 Correct 6 ms 10048 KB Output is correct
63 Correct 6 ms 10044 KB Output is correct
64 Correct 6 ms 9792 KB Output is correct
65 Correct 7 ms 10048 KB Output is correct
66 Correct 7 ms 9792 KB Output is correct
67 Correct 10 ms 9792 KB Output is correct
68 Correct 7 ms 9988 KB Output is correct
69 Correct 6 ms 10044 KB Output is correct
70 Correct 6 ms 10300 KB Output is correct
71 Correct 7 ms 10044 KB Output is correct
72 Correct 8 ms 9928 KB Output is correct
73 Correct 7 ms 10048 KB Output is correct
74 Correct 8 ms 10300 KB Output is correct
75 Correct 9 ms 10048 KB Output is correct
76 Correct 12 ms 9984 KB Output is correct
77 Correct 8 ms 9792 KB Output is correct
78 Correct 6 ms 9968 KB Output is correct
79 Correct 6 ms 9820 KB Output is correct
80 Correct 8 ms 10048 KB Output is correct
81 Correct 7 ms 9980 KB Output is correct
82 Correct 8 ms 9984 KB Output is correct
83 Correct 8 ms 10048 KB Output is correct
84 Correct 6 ms 10048 KB Output is correct
85 Correct 7 ms 10044 KB Output is correct
86 Correct 9 ms 9804 KB Output is correct
87 Correct 6 ms 9984 KB Output is correct
88 Correct 192 ms 25356 KB Output is correct
89 Correct 171 ms 25360 KB Output is correct
90 Correct 398 ms 48188 KB Output is correct
91 Correct 105 ms 23608 KB Output is correct
92 Correct 104 ms 23548 KB Output is correct
93 Correct 277 ms 40772 KB Output is correct
94 Correct 263 ms 40756 KB Output is correct
95 Correct 437 ms 48016 KB Output is correct
96 Correct 225 ms 26056 KB Output is correct
97 Correct 506 ms 47924 KB Output is correct
98 Correct 383 ms 47984 KB Output is correct
99 Correct 393 ms 46900 KB Output is correct
100 Correct 393 ms 46896 KB Output is correct
101 Correct 104 ms 23496 KB Output is correct
102 Correct 101 ms 23548 KB Output is correct
103 Correct 288 ms 40752 KB Output is correct
104 Correct 262 ms 40752 KB Output is correct
105 Correct 434 ms 48060 KB Output is correct
106 Correct 369 ms 48084 KB Output is correct
107 Correct 332 ms 46868 KB Output is correct
108 Correct 338 ms 47120 KB Output is correct
109 Correct 246 ms 32192 KB Output is correct
110 Correct 213 ms 32108 KB Output is correct
111 Correct 233 ms 36288 KB Output is correct
112 Correct 229 ms 36120 KB Output is correct