답안 #980136

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
980136 2024-05-12T00:09:01 Z vjudge1 봉쇄 시간 (IOI23_closing) C++17
0 / 100
154 ms 29140 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;

const long long oo = 1e14;

int x, y, n;

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


struct Nodo
{

    vector <Arista> ady;

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

struct Estado
{
    bool operator< (Estado otro) const
    {
        return p <otro.p;
    }

    long long p;
    int idx;
};

vector <Nodo> tree;


int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    
    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> pq;

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

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

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

        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 * -1);
    }

    int resp = 0;
    long long sum = 0;


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

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

Compilation message

closing.cpp: In function 'int max_score(int, int, int, long long int, std::vector<int>, std::vector<int>, std::vector<int>)':
closing.cpp:51:29: warning: control reaches end of non-void function [-Wreturn-type]
   51 |     priority_queue <Estado> pq;
      |                             ^~
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 154 ms 29140 KB 1st lines differ - on the 1st token, expected: '451', found: '22653146'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 1 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -
# 결과 실행 시간 메모리 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 -