Submission #1000357

# Submission time Handle Problem Language Result Execution time Memory
1000357 2024-06-17T10:12:42 Z sofijavelkovska Closing Time (IOI23_closing) C++17
8 / 100
68 ms 22228 KB
//#include "closing.h"

#include <bits/stdc++.h>
using namespace std;

const long long INF=1e18;

int max_score(int N, int X, int Y, long long K, vector<int> U, vector<int> V, vector<int> W)
{
    int n=N, s1=X, s2=Y;
    long long k=K;
    vector<pair<int, int> > adj[n];
    for (int i=0; i<n-1; i++)
    {
        adj[U[i]].push_back({V[i], W[i]});
        adj[V[i]].push_back({U[i], W[i]});
    }
    long long dist[n];
    for (int i=0; i<n; i++)
        dist[i]=INF;
    dist[s1]=0;
    dist[s2]=0;
    bool visited[n]={false};
    priority_queue<pair<long long, int> > pq;
    pq.push({0, s1});
    pq.push({0, s2});
    long long left=k;
    int total=0;
    while (!pq.empty())
    {
        long long d=-pq.top().first;
        int x=pq.top().second;
        pq.pop();
        if (visited[x])
            continue;
        visited[x]=true;
        if (left<d)
            break;
        left=left-d;
        total=total+1;
        for (auto edge : adj[x])
        {
            int y=edge.first;
            int dt=edge.second;
            if (d+dt<dist[y])
            {
                dist[y]=d+dt;
                pq.push({-dist[y], y});
            }
        }
    }

    return total;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 65 ms 18936 KB Output is correct
2 Correct 68 ms 22228 KB Output is correct
3 Correct 45 ms 5212 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 0 ms 348 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 0 ms 348 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 0 ms 348 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 0 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -