답안 #842010

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
842010 2023-09-02T10:08:53 Z danikoynov 봉쇄 시간 (IOI23_closing) C++17
컴파일 오류
0 ms 0 KB
#include "closing.h"
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const int maxn = 3e3 + 10;

vector < pair < int, ll > > adj[maxn];
ll dist[2][maxn];
int n;

void bfs(int s, ll arr[])
{
    queue < int > q;
    for (int i = 0; i < n; i ++)
        arr[i] = -1;

    arr[s] = 0;
    q.push(s);
    while(!q.empty())
    {
        int v = q.front();
        q.pop();
        for (pair < int, ll > nb : adj[v])
        {
            if (arr[nb.first] == -1)
            {
                arr[nb.first] = arr[v] + nb.second;
                q.push(nb.first);
            }
        }
    }
}
const ll inf = 1e18;

ll value[maxn];
ll dp[maxn][maxn * 2], sub[maxn], temp[maxn * 2];
int used[maxn];



vector < int > path;
bool get_path(int v, int p, int target)
{
    if (v == target)
    {
        path.push_back(v);
        return true;
    }

    for (pair < int, ll > nb : adj[v])
    {
        if (nb.first == p)
            continue;
        if (get_path(nb.first, v, target))
        {
            path.push_back(v);
            return true;
        }
    }
    return false;
}

int ans;

int max_score(int N, int X, int Y, long long K,
              vector<int> U, vector<int> V, vector<int> W)
{
    bigK = K;
    for (int i = 0; i < N; i ++)
    {
        dist[0][i] = dist[1][i] = 0;
        adj[i].clear();
        used[i] = 0;
        value[i] = 0;
    }
    n = 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]});
    }

    bfs(X, dist[0]);
    bfs(Y, dist[1]);

    path.clear();
    get_path(Y, -1, X);

    vector < ll > vec;
    for (int i = 0; i < N; i ++)
    {
        vec.push_back(dist[0][i]);
        vec.push_back(dist[1][i]);
    }

    sort(vec.begin(), vec.end());
    ll sum = 0;
    for (int i = 0; i < vec.size(); i ++)
    {
        sum += vec[i];
        if (sum > K)
            break;
        ans = max(ans, i + 1);
    }

    
    return ans;

}

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:70:5: error: 'bigK' was not declared in this scope
   70 |     bigK = K;
      |     ^~~~
closing.cpp:100:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
  100 |     for (int i = 0; i < vec.size(); i ++)
      |                     ~~^~~~~~~~~~~~