Submission #1064130

# Submission time Handle Problem Language Result Execution time Memory
1064130 2024-08-18T09:30:22 Z parsadox2 Closing Time (IOI23_closing) C++17
0 / 100
85 ms 31408 KB
#include "closing.h"
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
const int N = 2e5 + 10;
int n , x , y;
long long dis[2][N] , k;
vector <pair<int , int>> adj[N];

void Dfs(int v , int ty , int p = -1)
{
    for(auto u : adj[v])  if(u.F != p)
    {
        dis[ty][u.F] = dis[ty][v] + u.S;
        Dfs(u.F , ty , v);
    }
}

int max_score(int nn, int X, int Y, long long K,
              vector<int> U, vector<int> V, vector<int> W)
{
    n = nn;
    x = X;
    Y = y;
    k = K;
    for(int i = 0 ; i < n ; i++)
        adj[i].clear();
    for(int i = 0 ; i < n - 1 ; i++)
    {
        adj[U[i]].push_back(make_pair(V[i] , W[i]));
        adj[V[i]].push_back(make_pair(U[i] , W[i]));
    }
    dis[0][x] = 0;
    Dfs(x , 0);
    dis[1][y] = 0;
    Dfs(y , 1);
    vector <long long> all;
    for(int i = 0 ; i < n ; i++)
        all.push_back(min(dis[0][i] , dis[1][i]));
    sort(all.rbegin() , all.rend());
    int ans = 0;
    while(!all.empty() && k >= all.back())
    {
        k -= all.back();
        all.pop_back();
        ans++;
    }
    return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 85 ms 31408 KB 1st lines differ - on the 1st token, expected: '451', found: '565'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '3', found: '2'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '3'
2 Halted 0 ms 0 KB -