답안 #1095702

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1095702 2024-10-03T02:43:02 Z vjudge1 Construction Project 2 (JOI24_ho_t2) C++17
100 / 100
161 ms 24756 KB
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
const int maxN=2e5+5;
const ll inf=2e18;
int n,m,s,t,l;
ll k;
struct duongdi
{
    int u;
    ll w;
    bool operator < (const duongdi &o)const
    {
        return w>o.w;
    }
};
ll d[2][maxN+1];
vector<duongdi> adj[maxN+1];
priority_queue<duongdi> pq;
void dijkstra(int s,int type)
{
    for(int i=1;i<=n;i++)
    {
        d[type][i]=inf;
    }
    d[type][s]=0;
    pq.push({s,0});
    while(!pq.empty())
    {
        duongdi tmp=pq.top();
        pq.pop();
        int u=tmp.u;
        ll w=tmp.w;
        if(d[type][u]<w)
        {
            continue;
        }
        for(auto [v,nw]:adj[u])
        {
            if(d[type][v]>d[type][u]+nw)
            {
                d[type][v]=d[type][u]+nw;
                pq.push({v,d[type][v]});
            }
        }
    }
}
int main()
{
    //freopen("","r",stdin);
    //freopen("","w",stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>m>>s>>t>>l>>k;
    for(int i=1;i<=m;i++)
    {
        int u,v,w;
        cin>>u>>v>>w;
        adj[u].push_back({v,w});
        adj[v].push_back({u,w});
    }
    dijkstra(s,0);
    dijkstra(t,1);
    if(d[0][t]<=k)
    {
        cout<<1LL*n*(n-1)/2;
        return 0;
    }
    sort(d[0]+1,d[0]+n+1);
    sort(d[1]+1,d[1]+n+1);
    ll ans=0;
    for(int i=1,j=n;i<=n;i++)
    {
        while(j>0&&d[0][i]+d[1][j]+l>k)
        {
            j--;
        }
        ans+=j;
    }
    cout<<ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 4 ms 4956 KB Output is correct
5 Correct 3 ms 5212 KB Output is correct
6 Correct 3 ms 5212 KB Output is correct
7 Correct 57 ms 17212 KB Output is correct
8 Correct 64 ms 17092 KB Output is correct
9 Correct 61 ms 18356 KB Output is correct
10 Correct 2 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 35 ms 13488 KB Output is correct
15 Correct 122 ms 19260 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 3 ms 5268 KB Output is correct
18 Correct 71 ms 17472 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 5208 KB Output is correct
22 Correct 3 ms 5144 KB Output is correct
23 Correct 34 ms 13404 KB Output is correct
24 Correct 111 ms 19156 KB Output is correct
25 Correct 3 ms 4956 KB Output is correct
26 Correct 3 ms 5220 KB Output is correct
27 Correct 67 ms 22284 KB Output is correct
28 Correct 49 ms 16700 KB Output is correct
29 Correct 58 ms 15440 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 2 ms 4952 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 4956 KB Output is correct
18 Correct 2 ms 4952 KB Output is correct
19 Correct 2 ms 5012 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 3 ms 4956 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 2 ms 4976 KB Output is correct
24 Correct 2 ms 4956 KB Output is correct
25 Correct 2 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 2 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 2 ms 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4952 KB Output is correct
8 Correct 3 ms 4956 KB Output is correct
9 Correct 2 ms 4952 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 2 ms 4956 KB Output is correct
13 Correct 2 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 2 ms 4956 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 4956 KB Output is correct
18 Correct 2 ms 4952 KB Output is correct
19 Correct 2 ms 5012 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 3 ms 4956 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 2 ms 4976 KB Output is correct
24 Correct 2 ms 4956 KB Output is correct
25 Correct 2 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 2 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 4 ms 5212 KB Output is correct
34 Correct 3 ms 5220 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 5212 KB Output is correct
39 Correct 3 ms 5212 KB Output is correct
40 Correct 3 ms 5464 KB Output is correct
41 Correct 3 ms 5212 KB Output is correct
42 Correct 2 ms 5212 KB Output is correct
43 Correct 3 ms 5212 KB Output is correct
44 Correct 4 ms 5208 KB Output is correct
45 Correct 3 ms 5212 KB Output is correct
46 Correct 3 ms 5400 KB Output is correct
47 Correct 3 ms 5208 KB Output is correct
48 Correct 3 ms 5224 KB Output is correct
49 Correct 3 ms 5212 KB Output is correct
50 Correct 2 ms 5212 KB Output is correct
51 Correct 3 ms 5212 KB Output is correct
52 Correct 3 ms 5208 KB Output is correct
53 Correct 4 ms 5404 KB Output is correct
54 Correct 4 ms 5464 KB Output is correct
55 Correct 4 ms 5212 KB Output is correct
56 Correct 3 ms 5212 KB Output is correct
57 Correct 3 ms 5296 KB Output is correct
58 Correct 3 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 4 ms 4956 KB Output is correct
5 Correct 3 ms 5212 KB Output is correct
6 Correct 3 ms 5212 KB Output is correct
7 Correct 57 ms 17212 KB Output is correct
8 Correct 64 ms 17092 KB Output is correct
9 Correct 61 ms 18356 KB Output is correct
10 Correct 2 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 35 ms 13488 KB Output is correct
15 Correct 122 ms 19260 KB Output is correct
16 Correct 3 ms 4956 KB Output is correct
17 Correct 3 ms 5268 KB Output is correct
18 Correct 71 ms 17472 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 5208 KB Output is correct
22 Correct 3 ms 5144 KB Output is correct
23 Correct 34 ms 13404 KB Output is correct
24 Correct 111 ms 19156 KB Output is correct
25 Correct 3 ms 4956 KB Output is correct
26 Correct 3 ms 5220 KB Output is correct
27 Correct 67 ms 22284 KB Output is correct
28 Correct 49 ms 16700 KB Output is correct
29 Correct 58 ms 15440 KB Output is correct
30 Correct 2 ms 4956 KB Output is correct
31 Correct 2 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 2 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 4952 KB Output is correct
37 Correct 3 ms 4956 KB Output is correct
38 Correct 2 ms 4952 KB Output is correct
39 Correct 2 ms 4956 KB Output is correct
40 Correct 2 ms 4956 KB Output is correct
41 Correct 2 ms 4956 KB Output is correct
42 Correct 2 ms 4956 KB Output is correct
43 Correct 2 ms 4956 KB Output is correct
44 Correct 2 ms 4956 KB Output is correct
45 Correct 2 ms 4956 KB Output is correct
46 Correct 2 ms 4956 KB Output is correct
47 Correct 2 ms 4952 KB Output is correct
48 Correct 2 ms 5012 KB Output is correct
49 Correct 2 ms 4956 KB Output is correct
50 Correct 3 ms 4956 KB Output is correct
51 Correct 2 ms 4956 KB Output is correct
52 Correct 2 ms 4976 KB Output is correct
53 Correct 2 ms 4956 KB Output is correct
54 Correct 2 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 2 ms 4956 KB Output is correct
61 Correct 2 ms 4956 KB Output is correct
62 Correct 4 ms 5212 KB Output is correct
63 Correct 3 ms 5220 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 5212 KB Output is correct
68 Correct 3 ms 5212 KB Output is correct
69 Correct 3 ms 5464 KB Output is correct
70 Correct 3 ms 5212 KB Output is correct
71 Correct 2 ms 5212 KB Output is correct
72 Correct 3 ms 5212 KB Output is correct
73 Correct 4 ms 5208 KB Output is correct
74 Correct 3 ms 5212 KB Output is correct
75 Correct 3 ms 5400 KB Output is correct
76 Correct 3 ms 5208 KB Output is correct
77 Correct 3 ms 5224 KB Output is correct
78 Correct 3 ms 5212 KB Output is correct
79 Correct 2 ms 5212 KB Output is correct
80 Correct 3 ms 5212 KB Output is correct
81 Correct 3 ms 5208 KB Output is correct
82 Correct 4 ms 5404 KB Output is correct
83 Correct 4 ms 5464 KB Output is correct
84 Correct 4 ms 5212 KB Output is correct
85 Correct 3 ms 5212 KB Output is correct
86 Correct 3 ms 5296 KB Output is correct
87 Correct 3 ms 5212 KB Output is correct
88 Correct 85 ms 18900 KB Output is correct
89 Correct 87 ms 18896 KB Output is correct
90 Correct 81 ms 19024 KB Output is correct
91 Correct 41 ms 15440 KB Output is correct
92 Correct 42 ms 15460 KB Output is correct
93 Correct 38 ms 13400 KB Output is correct
94 Correct 39 ms 13404 KB Output is correct
95 Correct 159 ms 21964 KB Output is correct
96 Correct 120 ms 21708 KB Output is correct
97 Correct 144 ms 21072 KB Output is correct
98 Correct 139 ms 21328 KB Output is correct
99 Correct 71 ms 20056 KB Output is correct
100 Correct 64 ms 20028 KB Output is correct
101 Correct 47 ms 17488 KB Output is correct
102 Correct 48 ms 17492 KB Output is correct
103 Correct 47 ms 14672 KB Output is correct
104 Correct 43 ms 14676 KB Output is correct
105 Correct 161 ms 21884 KB Output is correct
106 Correct 152 ms 21776 KB Output is correct
107 Correct 140 ms 24756 KB Output is correct
108 Correct 134 ms 24668 KB Output is correct
109 Correct 70 ms 18736 KB Output is correct
110 Correct 69 ms 18740 KB Output is correct
111 Correct 89 ms 17872 KB Output is correct
112 Correct 88 ms 18016 KB Output is correct