Submission #844698

# Submission time Handle Problem Language Result Execution time Memory
844698 2023-09-05T17:15:10 Z oneloveforever Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ii pair<int,int>
#define ll long long
int n,a,b,k;
vector<vector<ii> >edge;
int Sub1()
{
    vector<vector<ll> >dist(2,vector<ll>(n+1,-1));
    vector<int>source(2);
    source[0]=a;
    source[1]=b;
    for(int i=0;i<=1;i++)
    {
        queue<int>q;
        q.push(source[i]);
        dist[i][source[i]]=0;
        while(!q.empty())
        {
            int x=q.front();
            q.pop();
            for(ii need:edge[x])
            {
                int node=need.x;
                int value=need.y;
                if(dist[i][node]==-1)
                {
                    dist[i][node]=dist[i][x]+value;
                    q.push(node);
                }
            }
        }
    }
    vector<ll>que;
    for(int i=0;i<=n-1;i++)
    {
        que.push_back(dist[0][i]);
        que.push_back(dist[1][i]);
    }
    sort(que.begin(),que.end());
    ll res=k;
    int ans=0;
    for(int value:que)
    {
        if(res<value)break;
        res-=value;
        ans++;
    }
    return ans;
}
int max_score(int N,int X,int Y,long long K,vector<int>U,vector<int>V,vector<int>W)
{
    n=N;
    a=X;
    b=Y;
    k=K;
    edge.resize(n);
    for(int i=0;i<N-1;i++)
    {
        int x=U[i];
        int y=V[i];
        int value=W[i];
        edge[x].push_back({y,value});
        edge[y].push_back({x,value});
    }
    return Sub1();


}

int main()
{
    int n,x,y,k;
    vector<int>U;
    vector<int>V;
    vector<int>W;
    cin>>n>>x>>y>>k;
    for(int i=1;i<=n-1;i++)
    {
        int x;
        cin>>x;
        U.push_back(x);
    }
    for(int i=1;i<=n-1;i++)
    {
        int y;
        cin>>y;
        V.push_back(y);
    }
    for(int i=1;i<=n-1;i++)
    {
        int value;
        cin>>value;
        W.push_back(value);
    }
    cout<<max_score(n,x,y,k,U,V,W);
}

Compilation message

/usr/bin/ld: /tmp/ccD4Szdt.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccny3OMu.o:closing.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status