답안 #839995

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
839995 2023-08-31T00:21:00 Z math_rabbit_1028 봉쇄 시간 (IOI23_closing) C++17
컴파일 오류
0 ms 0 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;

ll n, x, y, ch[202020], ans;
ll k;
vector<pll> adj[202020];
priority_queue<pll> pq;

ll max_score(ll N, ll X, ll Y, ll K, vector<ll> U, vector<ll> V, vector<ll> W) {
    n = N, x = X, y = Y, k = K;

    ans = 0;
    for (ll i = 0; i < n; i++) ch[i] = 0;
    for (ll i = 0; i < n; i++) adj[i].clear();
    if (!pq.empty()) pq.pop();

    for (ll i = 0; i < (ll)U.size(); i++) {
        adj[U[i]].push_back({V[i], W[i]});
        adj[V[i]].push_back({U[i], W[i]});
    }

    pq.push({-0, x});
    pq.push({-0, y});

    while (!pq.empty()) {
        ll v = pq.top().second; ll w = -pq.top().first;
        pq.pop();
        //cout << v << " " << w << "\n";
        if (k - w >= 0) {
            ans++;
            k -= w;
        }
        else break;
        
        ch[v] = 1;
        for (ll i = 0; i < (ll)adj[v].size(); i++) {
            if (ch[adj[v][i].first] == 1) continue;
            pq.push({-w-adj[v][i].second, adj[v][i].first});
        }
    }

    return ans;
}

Compilation message

/usr/bin/ld: /tmp/ccNU26aI.o: in function `main':
grader.cpp:(.text.startup+0x6a1): undefined reference to `max_score(int, int, int, long long, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status