Submission #1094179

# Submission time Handle Problem Language Result Execution time Memory
1094179 2024-09-28T19:36:26 Z Marco_Escandon Construction Project 2 (JOI24_ho_t2) C++11
45 / 100
2000 ms 23756 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());
    for(int i=0; i<=n; i++)
    {
        ll j=n;
        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 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 5 ms 604 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Execution timed out 2097 ms 23756 KB Time limit exceeded
8 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 344 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 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 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 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 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 1 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 344 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 1 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 344 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 1 ms 344 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 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 1 ms 344 KB Output is correct
19 Correct 0 ms 344 KB Output is correct
20 Correct 0 ms 344 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 1 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 344 KB Output is correct
32 Correct 0 ms 348 KB Output is correct
33 Correct 7 ms 600 KB Output is correct
34 Correct 1 ms 856 KB Output is correct
35 Correct 6 ms 704 KB Output is correct
36 Correct 6 ms 604 KB Output is correct
37 Correct 5 ms 600 KB Output is correct
38 Correct 6 ms 604 KB Output is correct
39 Correct 6 ms 604 KB Output is correct
40 Correct 1 ms 860 KB Output is correct
41 Correct 2 ms 824 KB Output is correct
42 Correct 6 ms 600 KB Output is correct
43 Correct 6 ms 824 KB Output is correct
44 Correct 6 ms 604 KB Output is correct
45 Correct 5 ms 712 KB Output is correct
46 Correct 5 ms 604 KB Output is correct
47 Correct 6 ms 604 KB Output is correct
48 Correct 7 ms 760 KB Output is correct
49 Correct 1 ms 824 KB Output is correct
50 Correct 5 ms 700 KB Output is correct
51 Correct 7 ms 676 KB Output is correct
52 Correct 5 ms 604 KB Output is correct
53 Correct 6 ms 900 KB Output is correct
54 Correct 7 ms 860 KB Output is correct
55 Correct 2 ms 604 KB Output is correct
56 Correct 2 ms 600 KB Output is correct
57 Correct 4 ms 604 KB Output is correct
58 Correct 3 ms 604 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 5 ms 604 KB Output is correct
6 Correct 1 ms 860 KB Output is correct
7 Execution timed out 2097 ms 23756 KB Time limit exceeded
8 Halted 0 ms 0 KB -