Submission #969313

# Submission time Handle Problem Language Result Execution time Memory
969313 2024-04-24T23:47:14 Z angels Closing Time (IOI23_closing) C++17
0 / 100
173 ms 29216 KB
#include "closing.h"

#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int>>a[200001];
void dfs(int x, long long int d, long long int dist[], bool visited[])
{
    visited[x]=1;
    dist[x]=d;
    for(int i=0; i<a[x].size(); i++)
    {
        if(!visited[a[x][i].first])
        {
            dfs(a[x][i].first, d+a[x][i].second, dist, visited);
        }
    }
}

int max_score(int N, int X, int Y, long long K, std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    int n=N, x=X, y=Y;
    long long k=K;
    for(int i=0; i<n-1; i++)
    {
        a[U[i]].push_back({V[i], W[i]});
        a[V[i]].push_back({U[i], W[i]});
    }
    bool visited[n];
    memset(visited, 0, sizeof(visited));
    long long int dist1[n], dist2[n];
    dfs(x, 0, dist1, visited);
    memset(visited, 0, sizeof(visited));
    dfs(y, 0, dist2, visited);
    long long int dist[2*n];
    int j=0, j1=n;
    for(int i=0; i<n; i++)
    {
        dist[j]=dist1[i];
        dist[j1]=dist2[i];
        j++; j1++;
    }
    sort(dist, dist+2*n);
    int sol=0;
    long long kk=0;
    for(int i=0; i<n; i++)
    {
        kk+=dist[i];
        if(kk<=k)
            sol++;
        else
            break;
    }
    return sol;
}

Compilation message

closing.cpp: In function 'void dfs(int, long long int, long long int*, bool*)':
closing.cpp:10:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   10 |     for(int i=0; i<a[x].size(); i++)
      |                  ~^~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 113 ms 24656 KB Output is correct
2 Correct 125 ms 29216 KB Output is correct
3 Incorrect 173 ms 11860 KB 2nd lines differ - on the 1st token, expected: '38', found: '45'
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 2 ms 4968 KB 1st lines differ - on the 1st token, expected: '30', found: '20'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 2 ms 4968 KB 1st lines differ - on the 1st token, expected: '30', found: '20'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 4956 KB Output is correct
2 Incorrect 2 ms 4968 KB 1st lines differ - on the 1st token, expected: '30', found: '20'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -