답안 #1067573

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067573 2024-08-20T20:30:19 Z Dennis_Jason Construction Project 2 (JOI24_ho_t2) C++14
100 / 100
223 ms 30336 KB
#include <bitset>
#include <cmath>
#include <functional>
#include <algorithm>
#include <numeric>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#define pb push_back
#define MOD 1000000007
#define NMAX 200001
#define nl '\n'
#define INF 1e18
#define pii1 pair<int, pair<int,int>>  (1,(1,2));
#define pii pair<int,int>
#define tpl tuple<int,int,int,int,int>
#define int long long 
using namespace std;
ifstream fin("data.in");
ofstream fout("data.out");
/*
    ====================DEMONSTRATION======================



    =========================END===========================

 */
int n,m,s,t,l,k;
vector<int>v;
vector<vector<pii>>G(NMAX);
vector<int>dist_s,dist_t;
priority_queue<pii,vector<pii>,greater<pii>>pq;

void dijkstra(int node,vector<int>&dist)
{

    for(int i=0;i<n;++i)
        dist[i]=INF;
    dist[node]=0;
    pq.push({0,node});
    while(!pq.empty())
    {
        auto [dis,first]=pq.top();
        pq.pop();
        if(dist[first]<dis)
            continue;
        for(auto [u,w]:G[first])
        {
            if(dist[u]>dist[first]+w)
            {
                dist[u]=dist[first]+w;
                pq.push({dist[u],u});
            }
        }

    }
}
signed main() {

     cin>>n>>m;
     cin>>s>>t>>l>>k;
     s--;
     t--;
     dist_s.resize(n,INF);
     dist_t.resize(n,INF);
     for(int i=1;i<=m;++i)
     {
         int x,y,c;
         cin>>x>>y>>c;
         x--;
         y--;
         G[x].pb({y,c});
         G[y].pb({x,c});
     }

     dijkstra(s,dist_s);
     dijkstra(t,dist_t);
     if(dist_s[t]<=k)
     {
         cout<<(n*(n-1)/2);
         return 0;
     }

     sort(dist_t.begin(),dist_t.end());
     int ans=0;
     for(int i=0;i<n;++i)
     {
         int dis=k-l-dist_s[i];
         int pos= lower_bound(dist_t.begin(),dist_t.end(),dis+1)-dist_t.begin();
         ans+=pos;
     }
     cout<<ans;







    return 0;
}

Compilation message

Main.cpp: In function 'void dijkstra(long long int, std::vector<long long int>&)':
Main.cpp:57:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   57 |         auto [dis,first]=pq.top();
      |              ^
Main.cpp:61:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   61 |         for(auto [u,w]:G[first])
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 3 ms 5212 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
7 Correct 111 ms 18792 KB Output is correct
8 Correct 113 ms 18736 KB Output is correct
9 Correct 110 ms 18708 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 2 ms 4952 KB Output is correct
12 Correct 2 ms 5212 KB Output is correct
13 Correct 3 ms 5212 KB Output is correct
14 Correct 65 ms 13452 KB Output is correct
15 Correct 190 ms 19116 KB Output is correct
16 Correct 2 ms 4952 KB Output is correct
17 Correct 4 ms 5212 KB Output is correct
18 Correct 116 ms 17512 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 2 ms 5212 KB Output is correct
22 Correct 3 ms 5212 KB Output is correct
23 Correct 70 ms 13564 KB Output is correct
24 Correct 191 ms 19152 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 3 ms 5212 KB Output is correct
27 Correct 132 ms 23996 KB Output is correct
28 Correct 106 ms 17408 KB Output is correct
29 Correct 108 ms 15448 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 1 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 1 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 1 ms 4956 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 2 ms 4956 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 1 ms 4956 KB Output is correct
30 Correct 2 ms 4956 KB Output is correct
31 Correct 1 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4956 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 2 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 2 ms 4956 KB Output is correct
11 Correct 2 ms 4956 KB Output is correct
12 Correct 1 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 1 ms 4956 KB Output is correct
20 Correct 2 ms 4956 KB Output is correct
21 Correct 1 ms 4956 KB Output is correct
22 Correct 1 ms 4956 KB Output is correct
23 Correct 2 ms 4956 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 1 ms 4956 KB Output is correct
30 Correct 2 ms 4956 KB Output is correct
31 Correct 1 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 5 ms 5212 KB Output is correct
34 Correct 2 ms 5212 KB Output is correct
35 Correct 2 ms 5208 KB Output is correct
36 Correct 4 ms 5196 KB Output is correct
37 Correct 3 ms 5208 KB Output is correct
38 Correct 2 ms 5284 KB Output is correct
39 Correct 4 ms 5212 KB Output is correct
40 Correct 3 ms 5420 KB Output is correct
41 Correct 2 ms 5212 KB Output is correct
42 Correct 2 ms 5212 KB Output is correct
43 Correct 4 ms 5212 KB Output is correct
44 Correct 3 ms 5212 KB Output is correct
45 Correct 4 ms 5212 KB Output is correct
46 Correct 4 ms 5212 KB Output is correct
47 Correct 3 ms 5212 KB Output is correct
48 Correct 3 ms 5212 KB Output is correct
49 Correct 3 ms 5412 KB Output is correct
50 Correct 3 ms 5212 KB Output is correct
51 Correct 4 ms 5212 KB Output is correct
52 Correct 4 ms 5212 KB Output is correct
53 Correct 4 ms 5468 KB Output is correct
54 Correct 4 ms 5468 KB Output is correct
55 Correct 3 ms 5212 KB Output is correct
56 Correct 4 ms 5212 KB Output is correct
57 Correct 3 ms 5240 KB Output is correct
58 Correct 3 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 3 ms 5212 KB Output is correct
6 Correct 2 ms 5212 KB Output is correct
7 Correct 111 ms 18792 KB Output is correct
8 Correct 113 ms 18736 KB Output is correct
9 Correct 110 ms 18708 KB Output is correct
10 Correct 2 ms 4952 KB Output is correct
11 Correct 2 ms 4952 KB Output is correct
12 Correct 2 ms 5212 KB Output is correct
13 Correct 3 ms 5212 KB Output is correct
14 Correct 65 ms 13452 KB Output is correct
15 Correct 190 ms 19116 KB Output is correct
16 Correct 2 ms 4952 KB Output is correct
17 Correct 4 ms 5212 KB Output is correct
18 Correct 116 ms 17512 KB Output is correct
19 Correct 2 ms 4956 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 2 ms 5212 KB Output is correct
22 Correct 3 ms 5212 KB Output is correct
23 Correct 70 ms 13564 KB Output is correct
24 Correct 191 ms 19152 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 3 ms 5212 KB Output is correct
27 Correct 132 ms 23996 KB Output is correct
28 Correct 106 ms 17408 KB Output is correct
29 Correct 108 ms 15448 KB Output is correct
30 Correct 1 ms 4956 KB Output is correct
31 Correct 1 ms 4956 KB Output is correct
32 Correct 2 ms 4956 KB Output is correct
33 Correct 1 ms 4956 KB Output is correct
34 Correct 2 ms 4956 KB Output is correct
35 Correct 1 ms 4956 KB Output is correct
36 Correct 1 ms 4956 KB Output is correct
37 Correct 2 ms 4956 KB Output is correct
38 Correct 2 ms 4956 KB Output is correct
39 Correct 2 ms 4956 KB Output is correct
40 Correct 2 ms 4956 KB Output is correct
41 Correct 1 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 1 ms 4956 KB Output is correct
49 Correct 2 ms 4956 KB Output is correct
50 Correct 1 ms 4956 KB Output is correct
51 Correct 1 ms 4956 KB Output is correct
52 Correct 2 ms 4956 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 1 ms 4956 KB Output is correct
59 Correct 2 ms 4956 KB Output is correct
60 Correct 1 ms 4956 KB Output is correct
61 Correct 2 ms 4956 KB Output is correct
62 Correct 5 ms 5212 KB Output is correct
63 Correct 2 ms 5212 KB Output is correct
64 Correct 2 ms 5208 KB Output is correct
65 Correct 4 ms 5196 KB Output is correct
66 Correct 3 ms 5208 KB Output is correct
67 Correct 2 ms 5284 KB Output is correct
68 Correct 4 ms 5212 KB Output is correct
69 Correct 3 ms 5420 KB Output is correct
70 Correct 2 ms 5212 KB Output is correct
71 Correct 2 ms 5212 KB Output is correct
72 Correct 4 ms 5212 KB Output is correct
73 Correct 3 ms 5212 KB Output is correct
74 Correct 4 ms 5212 KB Output is correct
75 Correct 4 ms 5212 KB Output is correct
76 Correct 3 ms 5212 KB Output is correct
77 Correct 3 ms 5212 KB Output is correct
78 Correct 3 ms 5412 KB Output is correct
79 Correct 3 ms 5212 KB Output is correct
80 Correct 4 ms 5212 KB Output is correct
81 Correct 4 ms 5212 KB Output is correct
82 Correct 4 ms 5468 KB Output is correct
83 Correct 4 ms 5468 KB Output is correct
84 Correct 3 ms 5212 KB Output is correct
85 Correct 4 ms 5212 KB Output is correct
86 Correct 3 ms 5240 KB Output is correct
87 Correct 3 ms 5212 KB Output is correct
88 Correct 176 ms 23748 KB Output is correct
89 Correct 172 ms 23632 KB Output is correct
90 Correct 163 ms 23632 KB Output is correct
91 Correct 102 ms 18772 KB Output is correct
92 Correct 102 ms 19024 KB Output is correct
93 Correct 82 ms 15696 KB Output is correct
94 Correct 82 ms 15696 KB Output is correct
95 Correct 212 ms 24268 KB Output is correct
96 Correct 204 ms 24264 KB Output is correct
97 Correct 223 ms 23132 KB Output is correct
98 Correct 210 ms 23124 KB Output is correct
99 Correct 145 ms 22096 KB Output is correct
100 Correct 152 ms 22364 KB Output is correct
101 Correct 107 ms 18768 KB Output is correct
102 Correct 106 ms 19024 KB Output is correct
103 Correct 83 ms 15676 KB Output is correct
104 Correct 84 ms 15736 KB Output is correct
105 Correct 219 ms 24320 KB Output is correct
106 Correct 221 ms 24268 KB Output is correct
107 Correct 212 ms 30336 KB Output is correct
108 Correct 217 ms 28344 KB Output is correct
109 Correct 138 ms 21120 KB Output is correct
110 Correct 144 ms 21080 KB Output is correct
111 Correct 138 ms 19152 KB Output is correct
112 Correct 140 ms 19148 KB Output is correct