Submission #973609

# Submission time Handle Problem Language Result Execution time Memory
973609 2024-05-02T08:27:46 Z tamir1 Closing Time (IOI23_closing) C++17
0 / 100
106 ms 29212 KB
#include "closing.h"
#include <bits/stdc++.h>
#include <vector>
#define ll long long
#define ff first
#define ss second
using namespace std;
vector<pair<int,ll> > v[200001];
ll dis[2][200001],dist[200001];
void dfs(int x,int p,ll d,bool k){
	dis[k][x]=min(dis[k][x],d);
	for(pair<int,int> i:v[x]){
		if(i.ff!=p)
		dfs(i.ff,x,d+i.ss,k);
	}
}
int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
	for(int i=0;i<N;i++){
		v[i].clear();
		dis[0][i]=2*K+1;
		dis[1][i]=2*K+1;
	}
	for(int i=0;i<N-1;i++){
		v[U[i]].push_back({V[i],W[i]});
		v[V[i]].push_back({U[i],W[i]});
	}
	dfs(X,-1,0,0);
	dfs(Y,-1,0,1);
	for(int i=0;i<N;i++){
		dist[i]=min(dis[0][i],dis[1][i]);
	}
	sort(dist,dist+N);
	ll k=0;
	int ans=0;
	for(int i=0;i<N;i++){
		if(k+dist[i]<=K){
			k+=dist[i];
			ans++;
		}
		else break;
	}
    //if(dis[0][Y]>2*K) return ans;
    return 0;
}
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9564 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 106 ms 29212 KB 1st lines differ - on the 1st token, expected: '451', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 9560 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 9560 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 9560 KB 1st lines differ - on the 1st token, expected: '3', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9564 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9564 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9564 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9564 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 3 ms 9564 KB 1st lines differ - on the 1st token, expected: '6', found: '0'
2 Halted 0 ms 0 KB -