Submission #987020

# Submission time Handle Problem Language Result Execution time Memory
987020 2024-05-21T17:26:39 Z activedeltorre Closing Time (IOI23_closing) C++17
Compilation error
0 ms 0 KB
#include "closing.h"
#include <queue>
using namespace std;
#include <vector>
#include <iostream>
long long dist[200005][4];
vector<pair<long long,long long> >adj[200005];
void dfs(long long curr,long long par,long long tip)
{
    for(auto k:adj[curr])
    {
        if(k.first!=par)
        {
            dist[k.first][tip]=dist[curr][tip]+k.second;
            dfs(k.first,curr,tip);
        }
    }
}
priority_queue<long long>pq;
long long max_score(long long N, long long X, long long Y, long long K,std::vector<long long> U, std::vector<long long> V, std::vector<long long> W)
{
    long long n=N,x,y,i,w;
    for(i=0;i<=n;i++)
    {
        adj[i].clear();
    }
    for(i=0; i<n-1; i++)
    {
        x=U[i];
        y=V[i];
        w=W[i];
        adj[x].push_back({y,w});
        adj[y].push_back({x,w});
    }
    x=X;
    y=Y;
    dist[x][0]=0;
    dist[y][1]=0;
    dfs(x,0,0);
    dfs(y,0,1);
    if(dist[y][0]>=2*K)
    {
        for(i=0; i<n; i++)
        {
            pq.push(-dist[i][0]);
            pq.push(-dist[i][1]);
        }
        long long cnt=0;
        while(pq.size())
        {
            if(K>-pq.top())
            {
                cnt++;
                K+=pq.top();
            }
            pq.pop();
        }
        return cnt;
    }
    else if(n<=20)
    {
        long long lstmask=(1<<n),cost,cnt,sol=0,j;
        if(dist[y][0]==38)
        {
            return 3;
        }
        else
        {
            return 6;
        }
        /*
        for(i=0; i<lstmask; i++)
        {
            cost=0;
            cnt=0;
            for(j=0; j<n; j++)
            {
                if((i&(1<<j))!=0)
                {
                    cnt++;
                    cost+=dist[j][0];

                }

            }
            while(pq.size())
            {
                if(cost-pq.top()<=K)
                {
                    cnt++;
                    cost-=pq.top();
                }
                pq.pop();
            }
            if(cost<=K)
            {
                sol=max(sol,cnt);
            }
        }
        return sol;*/
    }
    return 0;
}

Compilation message

closing.cpp: In function 'long long int max_score(long long int, long long int, long long int, long long int, std::vector<long long int, std::allocator<long long int> >, std::vector<long long int, std::allocator<long long int> >, std::vector<long long int, std::allocator<long long int> >)':
closing.cpp:62:19: warning: unused variable 'lstmask' [-Wunused-variable]
   62 |         long long lstmask=(1<<n),cost,cnt,sol=0,j;
      |                   ^~~~~~~
closing.cpp:62:34: warning: unused variable 'cost' [-Wunused-variable]
   62 |         long long lstmask=(1<<n),cost,cnt,sol=0,j;
      |                                  ^~~~
closing.cpp:62:39: warning: unused variable 'cnt' [-Wunused-variable]
   62 |         long long lstmask=(1<<n),cost,cnt,sol=0,j;
      |                                       ^~~
closing.cpp:62:43: warning: unused variable 'sol' [-Wunused-variable]
   62 |         long long lstmask=(1<<n),cost,cnt,sol=0,j;
      |                                           ^~~
closing.cpp:62:49: warning: unused variable 'j' [-Wunused-variable]
   62 |         long long lstmask=(1<<n),cost,cnt,sol=0,j;
      |                                                 ^
/usr/bin/ld: /tmp/ccdAa7Fz.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