답안 #1000356

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1000356 2024-06-17T10:11:02 Z sofijavelkovska 봉쇄 시간 (IOI23_closing) C++17
0 / 100
61 ms 22468 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=2;
    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;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 61 ms 22468 KB 1st lines differ - on the 1st token, expected: '451', found: '453'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '7'
2 Halted 0 ms 0 KB -