Submission #844666

# Submission time Handle Problem Language Result Execution time Memory
844666 2023-09-05T16:26:07 Z oneloveforever Closing Time (IOI23_closing) C++17
0 / 100
84 ms 20584 KB
#include "closing.h"
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define ii pair<int,int>
int n,a,b,k;
vector<vector<ii> >edge;
int Sub1()
{
    queue<int>q;
    vector<vector<int> >dist(2,vector<int>(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);
                }
            }
        }
    }
    if(dist[0][source[1]]<2*k)return -1;
    priority_queue<int,vector<int>,greater<int> >p;
    for(int i=1;i<=n;i++)
    {
        if(dist[0][i]<=k)p.push(dist[0][i]);
        if(dist[1][i]<=k)p.push(dist[1][i]);
    }
    int res=k;
    int ans=0;
    while(!p.empty())
    {
        int x=p.top();
        p.pop();
        if(res<x)break;
        res-=x;
        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+1;
    b=Y+1;
    k=K;
    edge.resize(n+1);
    for(int i=1;i<=N-1;i++)
    {
        int x=U[i-1]+1;
        int y=V[i-1]+1;
        int value=W[i-1];
        edge[x].push_back({y,value});
        edge[y].push_back({x,value});
    }
    int value=Sub1();
    if(value!=-1)return value;

}

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:75:1: warning: control reaches end of non-void function [-Wreturn-type]
   75 | }
      | ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 84 ms 20584 KB 1st lines differ - on the 1st token, expected: '451', found: '628'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '3', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '-1'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '-1'
2 Halted 0 ms 0 KB -