Submission #1081894

# Submission time Handle Problem Language Result Execution time Memory
1081894 2024-08-30T12:37:19 Z LaMatematica14 Closing Time (IOI23_closing) C++17
8 / 100
114 ms 27592 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;

int max_score(int N, int X, int Y, long long K,vector<int> U, vector<int> V, vector<int> W) {
    vector<vector<array<long long, 2>>> adj(N);
    for (long long i = 0; i < N-1; i++ ) {
        adj[U[i]].push_back({V[i], W[i]});
        adj[V[i]].push_back({U[i], W[i]});
    }
    vector<long long> d;
    vector<long long> dx(N, 1e15); dx[X] = 0;
    priority_queue<pair<long long, long long>> pq; 
    pq.push({0, X});
    while (!pq.empty()) {
        long long a = pq.top().second; pq.pop();
        for (auto x : adj[a]) {
            if (dx[x[0]] > dx[a]+x[1]) {
                dx[x[0]] = dx[a]+x[1];
                pq.push({-dx[x[0]], x[0]});
            }
        }
    }
    vector<long long> dy(N, 1e15); dy[Y] = 0;
    pq.push({0, Y});
    while (!pq.empty()) {
        long long a = pq.top().second; pq.pop();
        for (auto x : adj[a]) {
            if (dy[x[0]] > dy[a]+x[1]) {
                dy[x[0]] = dy[a]+x[1];
                pq.push({-dy[x[0]], x[0]});
            }
        }
    }
    for (long long i = 0; i < N; i++) {
        d.push_back(dx[i]); d.push_back(dy[i]);
    }
    sort(d.begin(), d.end());
    long long att = 0, k = 0;
    while (k < 2*N && att+d[k] <= K) {
        att += d[k]; k++;
    }
    return k;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 27592 KB Output is correct
2 Correct 114 ms 27480 KB Output is correct
3 Correct 69 ms 2928 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '24'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -