Submission #993981

# Submission time Handle Problem Language Result Execution time Memory
993981 2024-06-07T00:00:48 Z aaaaaarroz Closing Time (IOI23_closing) C++17
8 / 100
156 ms 41148 KB
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

vector<vector<pair<ll,ll>>>graph;
vector<bool> vis;
void dfs(vector<ll> &dist, int x, ll d){
    vis[x] = true;
    dist[x] = d;
    for (auto [y, w] : graph[x]){
        if (!vis[y]){
            dfs(dist, y, d + w);
        }
    }
}
int max_score(int N, int X, int Y, ll K, vector<int> U, vector<int> V, vector<int> W){
	graph.assign(N,vector<pair<ll,ll>>());
	for(int i=0;i<(N-1);i++){
		graph[U[i]].push_back({V[i],W[i]});
		graph[V[i]].push_back({U[i],W[i]});
	}
	//Calculo de distancia.
	vis.assign(N,false);
	vector<ll>distX(N);
	dfs(distX,X,0);
	vis.assign(N,false);
	vector<ll>distY(N);
	dfs(distY,Y,0);
	vector<ll>closing(N,0);
	priority_queue<pair<ll,ll>,vector<pair<ll,ll>>,greater<pair<ll,ll>>>prioridad;
	for(int i=0;i<N;i++){
		prioridad.push({distX[i],i});
	}
	for(int i=0;i<N;i++){
		prioridad.push({distY[i],i});
	}
	int ans=0;
	while(!prioridad.empty()){
		ll peso=prioridad.top().first;
		ll nodo=prioridad.top().second;
		prioridad.pop();
		if((K+closing[nodo])>=peso){
			K+=closing[nodo];
			K-=peso;
			closing[nodo]=peso;
			ans++;
		}
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 156 ms 38512 KB Output is correct
2 Correct 138 ms 41148 KB Output is correct
3 Correct 69 ms 2908 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Correct 0 ms 348 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 344 KB Output is correct
5 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '3', found: '4'
6 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 KB 2nd lines differ - on the 1st token, expected: '3', found: '4'
2 Halted 0 ms 0 KB -