답안 #1097479

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1097479 2024-10-07T12:58:03 Z hickwhither Construction Project 2 (JOI24_ho_t2) C++17
0 / 100
4 ms 5468 KB
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>

using namespace std;

#define int int64_t

const int MAXN = 2e5+3;
const int64_t INF = 1e18+69;
int n, m;

vector<pair<int,int>> e[MAXN];

int Start, End, lol, maximum;

int64_t ans;
int64_t f[2][MAXN];

void dijkstra(int s, int64_t f[]){
    fill(f+1,f+1+n,INF);

    priority_queue<pair<int64_t,int>, vector<pair<int64_t,int>>, greater<pair<int64_t,int>>> pq;
    pq.emplace(0, s);
    f[s] = 0;
    while(!pq.empty()){
        pair<int64_t,int> z = pq.top(); pq.pop();
        int64_t du = z.first;
        int u=z.second;
        if(du>f[u])continue;
        for(pair<int,int> &z : e[u]){
            int v=z.first, w=z.second;
            if(f[u]+w<f[v]){
                f[v] = f[u]+w;
                pq.emplace(f[v], v);
            }
        }
    }

}

signed main()
{
    cin.tie(0) -> sync_with_stdio(0);
    if(fopen("*.inp", "r")){
        freopen("*.inp", "r",stdin);
        freopen("*.out", "w",stdout);
    }
    
    cin >> n >> m;
    cin >> Start >> End >> lol >> maximum;
    for(int u, v, w, i=0; i<m; ++i){
        cin >> u >> v >> w;
        e[u].emplace_back(v, w);
        e[v].emplace_back(u, w);
    }
    dijkstra(Start, f[0]);
    dijkstra(End, f[1]);
    sort(f[0]+1, f[0]+1+n);
    sort(f[1]+1, f[1]+1+n);
    for(int i=1; i<=n; ++i){
        if(maximum<lol+f[1][i])break;
        auto x = upper_bound(f[0]+1, f[0]+1+n, maximum-lol-f[1][i]) - f[0];
        ans += x-1;
    }
    cout << ans;



    return 0;
}

Compilation message

Main.cpp: In function 'int main()':
Main.cpp:47:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   47 |         freopen("*.inp", "r",stdin);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~
Main.cpp:48:16: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   48 |         freopen("*.out", "w",stdout);
      |         ~~~~~~~^~~~~~~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 5248 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 5212 KB Output is correct
6 Incorrect 3 ms 5468 KB Output isn't correct
7 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5156 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 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 4 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 Incorrect 2 ms 5160 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 5156 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 4956 KB Output is correct
6 Correct 2 ms 4956 KB Output is correct
7 Correct 2 ms 4956 KB Output is correct
8 Correct 2 ms 4956 KB Output is correct
9 Correct 4 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 Incorrect 2 ms 5160 KB Output isn't correct
13 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Correct 2 ms 4956 KB Output is correct
3 Correct 2 ms 5248 KB Output is correct
4 Correct 2 ms 4956 KB Output is correct
5 Correct 2 ms 5212 KB Output is correct
6 Incorrect 3 ms 5468 KB Output isn't correct
7 Halted 0 ms 0 KB -