답안 #1067569

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1067569 2024-08-20T20:28:05 Z Dennis_Jason Construction Project 2 (JOI24_ho_t2) C++14
8 / 100
180 ms 28024 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 1000000007
#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 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 3 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 131 ms 18956 KB Output is correct
8 Correct 114 ms 18896 KB Output is correct
9 Correct 104 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 3 ms 5212 KB Output is correct
13 Correct 4 ms 5364 KB Output is correct
14 Correct 61 ms 14932 KB Output is correct
15 Correct 180 ms 22508 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 5212 KB Output is correct
18 Correct 122 ms 20396 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 5212 KB Output is correct
22 Correct 3 ms 5212 KB Output is correct
23 Correct 68 ms 14812 KB Output is correct
24 Correct 171 ms 22504 KB Output is correct
25 Correct 2 ms 4952 KB Output is correct
26 Correct 3 ms 5468 KB Output is correct
27 Correct 141 ms 28024 KB Output is correct
28 Correct 115 ms 20372 KB Output is correct
29 Correct 110 ms 18204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Incorrect 1 ms 4956 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 1 ms 4956 KB Output is correct
3 Correct 1 ms 4956 KB Output is correct
4 Incorrect 1 ms 4956 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 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 3 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 131 ms 18956 KB Output is correct
8 Correct 114 ms 18896 KB Output is correct
9 Correct 104 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 3 ms 5212 KB Output is correct
13 Correct 4 ms 5364 KB Output is correct
14 Correct 61 ms 14932 KB Output is correct
15 Correct 180 ms 22508 KB Output is correct
16 Correct 2 ms 4956 KB Output is correct
17 Correct 2 ms 5212 KB Output is correct
18 Correct 122 ms 20396 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 5212 KB Output is correct
22 Correct 3 ms 5212 KB Output is correct
23 Correct 68 ms 14812 KB Output is correct
24 Correct 171 ms 22504 KB Output is correct
25 Correct 2 ms 4952 KB Output is correct
26 Correct 3 ms 5468 KB Output is correct
27 Correct 141 ms 28024 KB Output is correct
28 Correct 115 ms 20372 KB Output is correct
29 Correct 110 ms 18204 KB Output is correct
30 Correct 2 ms 4952 KB Output is correct
31 Correct 1 ms 4956 KB Output is correct
32 Correct 1 ms 4956 KB Output is correct
33 Incorrect 1 ms 4956 KB Output isn't correct
34 Halted 0 ms 0 KB -