답안 #1067574

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067574 2024-08-20T20:31:10 Z Dennis_Jason Construction Project 2 (JOI24_ho_t2) C++14
53 / 100
2000 ms 24836 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;
void dijkstra(int node,vector<int>&dist)
{
    priority_queue<pii,vector<pii>,greater<pii>>pq;
    for(int i=1;i<=n;++i)
        dist[i]=INF;
    dist[node]=0;
    pq.push({0,node});
    while(!pq.empty())
    {
        auto [dis,first]=pq.top();
        pq.pop();
        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;
     dist_s.resize(n+1);
     dist_t.resize(n+1);
     for(int i=1;i<=m;++i)
     {
         int x,y,c;
         cin>>x>>y>>c;
         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()+1,dist_t.end());
     int ans=0;
     for(int i=1;i<=n;++i)
     {
         int dis=k-l-dist_s[i];
         int st=1;
         int dr=n;
         int pos=0;
         while(st<=dr)
         {
             int mid=(st+dr)/2;
             if(dist_t[mid]<=dis)
             {
                 pos=mid;
                 st=mid+1;
             }
             else
                 dr=mid-1;
         }
         ans+=pos;
     }
     cout<<ans;
 
 
 
 
 
 
 
    return 0;
}

Compilation message

Main.cpp: In function 'void dijkstra(long long int, std::vector<long long int>&)':
Main.cpp:55:14: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   55 |         auto [dis,first]=pq.top();
      |              ^
Main.cpp:57:18: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   57 |         for(auto [u,w]:G[first])
      |                  ^
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 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 3 ms 5212 KB Output is correct
7 Correct 96 ms 19088 KB Output is correct
8 Correct 113 ms 18892 KB Output is correct
9 Correct 105 ms 19544 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 5212 KB Output is correct
13 Correct 4 ms 5212 KB Output is correct
14 Correct 67 ms 13344 KB Output is correct
15 Correct 176 ms 19584 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 3 ms 5212 KB Output is correct
18 Correct 113 ms 17456 KB Output is correct
19 Correct 2 ms 4952 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 4 ms 5212 KB Output is correct
22 Correct 4 ms 5248 KB Output is correct
23 Correct 74 ms 13368 KB Output is correct
24 Correct 176 ms 19688 KB Output is correct
25 Correct 1 ms 4952 KB Output is correct
26 Correct 3 ms 5212 KB Output is correct
27 Correct 128 ms 24836 KB Output is correct
28 Correct 106 ms 18072 KB Output is correct
29 Correct 129 ms 15444 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 5036 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 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 1 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 1 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 1 ms 4956 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 4956 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 1 ms 4956 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 1 ms 4956 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4956 KB Output is correct
31 Correct 1 ms 4956 KB Output is correct
32 Correct 1 ms 4956 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4956 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 2 ms 4952 KB Output is correct
4 Correct 1 ms 4956 KB Output is correct
5 Correct 1 ms 4956 KB Output is correct
6 Correct 1 ms 4956 KB Output is correct
7 Correct 1 ms 5036 KB Output is correct
8 Correct 1 ms 4956 KB Output is correct
9 Correct 2 ms 4956 KB Output is correct
10 Correct 1 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 1 ms 4956 KB Output is correct
14 Correct 2 ms 4956 KB Output is correct
15 Correct 1 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 1 ms 4956 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 4956 KB Output is correct
22 Correct 2 ms 4956 KB Output is correct
23 Correct 2 ms 4956 KB Output is correct
24 Correct 1 ms 4956 KB Output is correct
25 Correct 2 ms 4956 KB Output is correct
26 Correct 1 ms 4956 KB Output is correct
27 Correct 2 ms 4956 KB Output is correct
28 Correct 1 ms 4956 KB Output is correct
29 Correct 1 ms 4956 KB Output is correct
30 Correct 1 ms 4956 KB Output is correct
31 Correct 1 ms 4956 KB Output is correct
32 Correct 1 ms 4956 KB Output is correct
33 Correct 2 ms 5212 KB Output is correct
34 Correct 2 ms 5212 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 2 ms 5212 KB Output is correct
39 Correct 3 ms 5316 KB Output is correct
40 Correct 3 ms 5212 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 5 ms 5464 KB Output is correct
45 Correct 5 ms 5212 KB Output is correct
46 Correct 5 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 5212 KB Output is correct
50 Correct 2 ms 5212 KB Output is correct
51 Correct 4 ms 5264 KB Output is correct
52 Correct 3 ms 5212 KB Output is correct
53 Correct 4 ms 5208 KB Output is correct
54 Correct 4 ms 5212 KB Output is correct
55 Correct 5 ms 5212 KB Output is correct
56 Correct 4 ms 5212 KB Output is correct
57 Correct 3 ms 5212 KB Output is correct
58 Correct 4 ms 5212 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 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 3 ms 5212 KB Output is correct
7 Correct 96 ms 19088 KB Output is correct
8 Correct 113 ms 18892 KB Output is correct
9 Correct 105 ms 19544 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 5212 KB Output is correct
13 Correct 4 ms 5212 KB Output is correct
14 Correct 67 ms 13344 KB Output is correct
15 Correct 176 ms 19584 KB Output is correct
16 Correct 1 ms 4956 KB Output is correct
17 Correct 3 ms 5212 KB Output is correct
18 Correct 113 ms 17456 KB Output is correct
19 Correct 2 ms 4952 KB Output is correct
20 Correct 1 ms 4956 KB Output is correct
21 Correct 4 ms 5212 KB Output is correct
22 Correct 4 ms 5248 KB Output is correct
23 Correct 74 ms 13368 KB Output is correct
24 Correct 176 ms 19688 KB Output is correct
25 Correct 1 ms 4952 KB Output is correct
26 Correct 3 ms 5212 KB Output is correct
27 Correct 128 ms 24836 KB Output is correct
28 Correct 106 ms 18072 KB Output is correct
29 Correct 129 ms 15444 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 4952 KB Output is correct
33 Correct 1 ms 4956 KB Output is correct
34 Correct 1 ms 4956 KB Output is correct
35 Correct 1 ms 4956 KB Output is correct
36 Correct 1 ms 5036 KB Output is correct
37 Correct 1 ms 4956 KB Output is correct
38 Correct 2 ms 4956 KB Output is correct
39 Correct 1 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 1 ms 4956 KB Output is correct
43 Correct 2 ms 4956 KB Output is correct
44 Correct 1 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 1 ms 4956 KB Output is correct
48 Correct 2 ms 4956 KB Output is correct
49 Correct 2 ms 4956 KB Output is correct
50 Correct 2 ms 4956 KB Output is correct
51 Correct 2 ms 4956 KB Output is correct
52 Correct 2 ms 4956 KB Output is correct
53 Correct 1 ms 4956 KB Output is correct
54 Correct 2 ms 4956 KB Output is correct
55 Correct 1 ms 4956 KB Output is correct
56 Correct 2 ms 4956 KB Output is correct
57 Correct 1 ms 4956 KB Output is correct
58 Correct 1 ms 4956 KB Output is correct
59 Correct 1 ms 4956 KB Output is correct
60 Correct 1 ms 4956 KB Output is correct
61 Correct 1 ms 4956 KB Output is correct
62 Correct 2 ms 5212 KB Output is correct
63 Correct 2 ms 5212 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 2 ms 5212 KB Output is correct
68 Correct 3 ms 5316 KB Output is correct
69 Correct 3 ms 5212 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 5 ms 5464 KB Output is correct
74 Correct 5 ms 5212 KB Output is correct
75 Correct 5 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 5212 KB Output is correct
79 Correct 2 ms 5212 KB Output is correct
80 Correct 4 ms 5264 KB Output is correct
81 Correct 3 ms 5212 KB Output is correct
82 Correct 4 ms 5208 KB Output is correct
83 Correct 4 ms 5212 KB Output is correct
84 Correct 5 ms 5212 KB Output is correct
85 Correct 4 ms 5212 KB Output is correct
86 Correct 3 ms 5212 KB Output is correct
87 Correct 4 ms 5212 KB Output is correct
88 Correct 172 ms 19028 KB Output is correct
89 Correct 158 ms 19020 KB Output is correct
90 Correct 162 ms 18920 KB Output is correct
91 Correct 103 ms 15440 KB Output is correct
92 Correct 106 ms 15700 KB Output is correct
93 Correct 74 ms 13396 KB Output is correct
94 Correct 74 ms 13396 KB Output is correct
95 Correct 233 ms 20084 KB Output is correct
96 Correct 221 ms 20160 KB Output is correct
97 Correct 206 ms 18504 KB Output is correct
98 Correct 207 ms 18512 KB Output is correct
99 Correct 139 ms 17488 KB Output is correct
100 Correct 142 ms 17484 KB Output is correct
101 Correct 101 ms 15444 KB Output is correct
102 Correct 117 ms 15696 KB Output is correct
103 Correct 77 ms 13392 KB Output is correct
104 Correct 81 ms 13392 KB Output is correct
105 Correct 224 ms 20128 KB Output is correct
106 Correct 226 ms 20100 KB Output is correct
107 Correct 228 ms 24828 KB Output is correct
108 Correct 217 ms 24828 KB Output is correct
109 Execution timed out 2102 ms 17456 KB Time limit exceeded
110 Halted 0 ms 0 KB -