Submission #1064149

# Submission time Handle Problem Language Result Execution time Memory
1064149 2024-08-18T09:39:01 Z parsadox2 Closing Time (IOI23_closing) C++17
8 / 100
96 ms 37168 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)
{
    //cout << v << " wtf: " << ty << " " << dis[ty][v] << endl;
    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]));
    }
    //cout << x << " " << y << endl;
    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++)
    {
        //cout << i << " : " << dis[0][i] << " " << dis[1][i] << endl;
        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 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 84 ms 27732 KB Output is correct
2 Correct 96 ms 37168 KB Output is correct
3 Correct 49 ms 10064 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Incorrect 3 ms 5212 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Incorrect 3 ms 5212 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4952 KB Output is correct
2 Incorrect 3 ms 5212 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 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 2 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 2 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 2 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 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -