Submission #1094180

# Submission time Handle Problem Language Result Execution time Memory
1094180 2024-09-28T19:36:52 Z Marco_Escandon Construction Project 2 (JOI24_ho_t2) C++11
100 / 100
190 ms 36256 KB
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define x first
#define y second
ll n,m;
vector<vector<pair<ll,ll>>> cad;
vector<pair<ll,ll>> Dijkstra(ll ini)
{
    vector<pair<ll,ll>> v(n+2, {1e16,1e16});
    priority_queue<pair<ll,pair<ll,ll>>>q;
    q.push({0,{ini,-1}});
    while(!q.empty())
    {
        pair<ll,pair<ll,ll>> a=q.top();q.pop();
        if(v[a.y.x].x==1e16)
        {
            v[a.y.x]={-a.x,a.y.y};
            for(auto i:cad[a.y.x])
                if(v[i.x].x==1e16)
                    q.push({a.x-i.y,{i.x,a.y.x}});
        }
    }
    return v;
};
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    cin>>n>>m;
    ll s,t,l,k;
    cin>>s>>t>>l>>k;
    cad.resize(n+1);
    for(int i=0; i<m; i++)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        cad[a].push_back({b,c});
        cad[b].push_back({a,c});
    }
    vector<pair<ll,ll>> vs=Dijkstra(s);
    vector<pair<ll,ll>> vt=Dijkstra(t);
    if(vs[t].x<=k)
    {
        cout<<n*(n-1)/2;
        return 0;
    }
    ll p=0;ll cont=0;
    sort(vs.begin(),vs.end());
    sort(vt.begin(),vt.end());
    ll j=n;
    for(int i=0; i<=n; i++)
    {
        while(j>=0&&vs[i].x+vt[j].x+l>k)
            j--;
        cont+=(j+1);
    }
    cout<<cont;
    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:48:8: warning: unused variable 'p' [-Wunused-variable]
   48 |     ll p=0;ll cont=0;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 61 ms 23776 KB Output is correct
8 Correct 76 ms 26316 KB Output is correct
9 Correct 68 ms 27064 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 47 ms 18004 KB Output is correct
15 Correct 190 ms 27136 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 79 ms 23636 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 2 ms 780 KB Output is correct
23 Correct 49 ms 18004 KB Output is correct
24 Correct 173 ms 27188 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 98 ms 34584 KB Output is correct
28 Correct 73 ms 21544 KB Output is correct
29 Correct 71 ms 18632 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 600 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 0 ms 348 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 348 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 0 ms 600 KB Output is correct
14 Correct 0 ms 348 KB Output is correct
15 Correct 0 ms 348 KB Output is correct
16 Correct 0 ms 348 KB Output is correct
17 Correct 0 ms 348 KB Output is correct
18 Correct 0 ms 348 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 0 ms 348 KB Output is correct
22 Correct 0 ms 348 KB Output is correct
23 Correct 0 ms 348 KB Output is correct
24 Correct 0 ms 348 KB Output is correct
25 Correct 0 ms 348 KB Output is correct
26 Correct 0 ms 348 KB Output is correct
27 Correct 0 ms 348 KB Output is correct
28 Correct 0 ms 348 KB Output is correct
29 Correct 0 ms 348 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 1 ms 856 KB Output is correct
34 Correct 1 ms 696 KB Output is correct
35 Correct 1 ms 604 KB Output is correct
36 Correct 2 ms 604 KB Output is correct
37 Correct 1 ms 600 KB Output is correct
38 Correct 1 ms 604 KB Output is correct
39 Correct 2 ms 604 KB Output is correct
40 Correct 2 ms 860 KB Output is correct
41 Correct 2 ms 824 KB Output is correct
42 Correct 1 ms 604 KB Output is correct
43 Correct 2 ms 604 KB Output is correct
44 Correct 2 ms 604 KB Output is correct
45 Correct 2 ms 604 KB Output is correct
46 Correct 2 ms 604 KB Output is correct
47 Correct 1 ms 604 KB Output is correct
48 Correct 1 ms 604 KB Output is correct
49 Correct 1 ms 824 KB Output is correct
50 Correct 1 ms 468 KB Output is correct
51 Correct 2 ms 604 KB Output is correct
52 Correct 1 ms 604 KB Output is correct
53 Correct 3 ms 860 KB Output is correct
54 Correct 2 ms 860 KB Output is correct
55 Correct 2 ms 604 KB Output is correct
56 Correct 1 ms 600 KB Output is correct
57 Correct 2 ms 604 KB Output is correct
58 Correct 2 ms 616 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 1 ms 604 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Correct 61 ms 23776 KB Output is correct
8 Correct 76 ms 26316 KB Output is correct
9 Correct 68 ms 27064 KB Output is correct
10 Correct 0 ms 344 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 1 ms 604 KB Output is correct
13 Correct 2 ms 860 KB Output is correct
14 Correct 47 ms 18004 KB Output is correct
15 Correct 190 ms 27136 KB Output is correct
16 Correct 0 ms 344 KB Output is correct
17 Correct 1 ms 600 KB Output is correct
18 Correct 79 ms 23636 KB Output is correct
19 Correct 0 ms 348 KB Output is correct
20 Correct 1 ms 348 KB Output is correct
21 Correct 1 ms 604 KB Output is correct
22 Correct 2 ms 780 KB Output is correct
23 Correct 49 ms 18004 KB Output is correct
24 Correct 173 ms 27188 KB Output is correct
25 Correct 1 ms 344 KB Output is correct
26 Correct 1 ms 860 KB Output is correct
27 Correct 98 ms 34584 KB Output is correct
28 Correct 73 ms 21544 KB Output is correct
29 Correct 71 ms 18632 KB Output is correct
30 Correct 0 ms 348 KB Output is correct
31 Correct 0 ms 348 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 0 ms 348 KB Output is correct
34 Correct 0 ms 348 KB Output is correct
35 Correct 0 ms 348 KB Output is correct
36 Correct 0 ms 348 KB Output is correct
37 Correct 0 ms 348 KB Output is correct
38 Correct 0 ms 348 KB Output is correct
39 Correct 0 ms 348 KB Output is correct
40 Correct 0 ms 348 KB Output is correct
41 Correct 0 ms 348 KB Output is correct
42 Correct 0 ms 600 KB Output is correct
43 Correct 0 ms 348 KB Output is correct
44 Correct 0 ms 348 KB Output is correct
45 Correct 0 ms 348 KB Output is correct
46 Correct 0 ms 348 KB Output is correct
47 Correct 0 ms 348 KB Output is correct
48 Correct 0 ms 348 KB Output is correct
49 Correct 1 ms 348 KB Output is correct
50 Correct 0 ms 348 KB Output is correct
51 Correct 0 ms 348 KB Output is correct
52 Correct 0 ms 348 KB Output is correct
53 Correct 0 ms 348 KB Output is correct
54 Correct 0 ms 348 KB Output is correct
55 Correct 0 ms 348 KB Output is correct
56 Correct 0 ms 348 KB Output is correct
57 Correct 0 ms 348 KB Output is correct
58 Correct 0 ms 348 KB Output is correct
59 Correct 0 ms 348 KB Output is correct
60 Correct 0 ms 348 KB Output is correct
61 Correct 0 ms 348 KB Output is correct
62 Correct 1 ms 856 KB Output is correct
63 Correct 1 ms 696 KB Output is correct
64 Correct 1 ms 604 KB Output is correct
65 Correct 2 ms 604 KB Output is correct
66 Correct 1 ms 600 KB Output is correct
67 Correct 1 ms 604 KB Output is correct
68 Correct 2 ms 604 KB Output is correct
69 Correct 2 ms 860 KB Output is correct
70 Correct 2 ms 824 KB Output is correct
71 Correct 1 ms 604 KB Output is correct
72 Correct 2 ms 604 KB Output is correct
73 Correct 2 ms 604 KB Output is correct
74 Correct 2 ms 604 KB Output is correct
75 Correct 2 ms 604 KB Output is correct
76 Correct 1 ms 604 KB Output is correct
77 Correct 1 ms 604 KB Output is correct
78 Correct 1 ms 824 KB Output is correct
79 Correct 1 ms 468 KB Output is correct
80 Correct 2 ms 604 KB Output is correct
81 Correct 1 ms 604 KB Output is correct
82 Correct 3 ms 860 KB Output is correct
83 Correct 2 ms 860 KB Output is correct
84 Correct 2 ms 604 KB Output is correct
85 Correct 1 ms 600 KB Output is correct
86 Correct 2 ms 604 KB Output is correct
87 Correct 2 ms 616 KB Output is correct
88 Correct 94 ms 27184 KB Output is correct
89 Correct 95 ms 27176 KB Output is correct
90 Correct 101 ms 26884 KB Output is correct
91 Correct 107 ms 25012 KB Output is correct
92 Correct 106 ms 25024 KB Output is correct
93 Correct 44 ms 18780 KB Output is correct
94 Correct 44 ms 18792 KB Output is correct
95 Correct 172 ms 28708 KB Output is correct
96 Correct 169 ms 28696 KB Output is correct
97 Correct 172 ms 26192 KB Output is correct
98 Correct 161 ms 26196 KB Output is correct
99 Correct 80 ms 25024 KB Output is correct
100 Correct 72 ms 25168 KB Output is correct
101 Correct 106 ms 24980 KB Output is correct
102 Correct 109 ms 25012 KB Output is correct
103 Correct 44 ms 18772 KB Output is correct
104 Correct 52 ms 18772 KB Output is correct
105 Correct 184 ms 28696 KB Output is correct
106 Correct 183 ms 28720 KB Output is correct
107 Correct 161 ms 35940 KB Output is correct
108 Correct 159 ms 36256 KB Output is correct
109 Correct 85 ms 26512 KB Output is correct
110 Correct 83 ms 26372 KB Output is correct
111 Correct 99 ms 20480 KB Output is correct
112 Correct 106 ms 20496 KB Output is correct