답안 #979936

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
979936 2024-05-11T16:37:12 Z alo_54 봉쇄 시간 (IOI23_closing) C++17
0 / 100
111 ms 25172 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;

int x, y, n;

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


struct Nodo
{
    vector <Arista> ady;

    long long distX, distY;
};

struct Estado
{
    long long p;
    int idx;
};

vector <Nodo> tree;

void bfs(int root, int n)
{
    queue <Estado> cola;
    vector <bool> vis (n, false);
    cola.push({0, root});
    vis[root] = true;

    while (!cola.empty())
    {
        Estado curr = cola.front();
        cola.pop();

        if (root == x)
        {
            tree[curr.idx].distX = curr.p;
        }

        if (root == y)
        {
            tree[curr.idx].distY = curr.p;
        }

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


int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    
    x = X; y = Y; n = N;
    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]});
    }

    bfs(X, N);
    bfs(Y, N);

    int resp = N;
    long long sum = 0;
    queue <long long> pq;

    for (auto i : tree)
    {
        pq.push(min(i.distX, i.distY)); 
        sum += (long long)min(i.distX, i.distY);
    }

    while (sum > K)
    {
        if (pq.empty())
        {
            break;
        }
        
        sum -= pq.front();
        pq.pop();
        resp--;
    }

    return resp;
    
    
}
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 111 ms 25172 KB 1st lines differ - on the 1st token, expected: '451', found: '0'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 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 0 ms 344 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 0 ms 344 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 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 1 ms 348 KB Execution killed with signal 11
2 Halted 0 ms 0 KB -