답안 #980846

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980846 2024-05-12T13:44:28 Z alo_54 봉쇄 시간 (IOI23_closing) C++17
8 / 100
108 ms 27116 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;

const long long oo = 1e14;

struct Arista
{
    int v;
    long long w;
};


struct Nodo
{

    vector <Arista> ady;

    long long dist, distP = oo;
    bool vis = false;
};

struct Estado
{

    long long p;
    int idx;
};

struct Comp
{
    bool operator() (Estado a, Estado b) const
    {
        return a.p > b.p;
    }
};





int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    vector <Nodo> tree;
    tree.resize(N);

    for (int i = 0; i < N-1; i++)
    {
        tree[U[i]].ady.push_back({V[i], W[i]});
        tree[V[i]].ady.push_back({U[i], W[i]});
    }

    priority_queue <Estado, vector <Estado>, Comp>pq;

    pq.push({0, X});
    pq.push({0, Y});

    tree[Y].distP = 0; 
    tree[X].distP = 0;

    while (!pq.empty())
    {
        Estado curr = pq.top();
        pq.pop();

        if (!tree[curr.idx].vis)
        {
            tree[curr.idx].dist = tree[curr.idx].distP;
            tree[curr.idx].vis = true;

            for (auto i : tree[curr.idx].ady)
            {
                if (!tree[i.v].vis)
                {
                    tree[i.v].distP = min(tree[i.v].distP, curr.p + i.w);
                    pq.push({tree[i.v].distP, i.v});
                }
            }
        }
        
 
    }

    priority_queue <long long> minW;

    for (auto i: tree)
    {
        minW.push(i.dist *(long long) -1);
    }

    int resp = 0;
    long long sum = 0;


    while (!minW.empty())
    {
        sum += minW.top()*(long long)-1;
        minW.pop();

        if (sum <= K)
        {
            resp ++;
        }else
        {
            break;
        }
         
    }

    return resp;
    
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 107 ms 26976 KB Output is correct
2 Correct 108 ms 27116 KB Output is correct
3 Correct 62 ms 2900 KB Output is correct
# 결과 실행 시간 메모리 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: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '6', 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: '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: '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: '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: '5'
2 Halted 0 ms 0 KB -