Submission #993980

# Submission time Handle Problem Language Result Execution time Memory
993980 2024-06-06T23:58:42 Z aaaaaarroz Closing Time (IOI23_closing) C++17
8 / 100
300 ms 60496 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);
	set<tuple<ll,ll,ll>>prioridad;
	for(int i=0;i<N;i++){
		prioridad.insert({distX[i],i,0});
	}
	for(int i=0;i<N;i++){
		prioridad.insert({distY[i],i,1});
	}
	int ans=0;
	vector<bool>v(N,false);
	while(!prioridad.empty()){
		auto[peso,nodo,from]=*prioridad.begin();
		prioridad.erase(prioridad.begin());
		if(K>=peso){
			K-=peso;
			closing[nodo]+=peso;
			if(from==0&&!v[nodo]){
				prioridad.erase({distY[nodo],nodo,1});
				prioridad.insert({distY[nodo]-peso,nodo,1});
			}
			else if(from==1&&!v[nodo]){
				prioridad.erase({distX[nodo],nodo,0});
				prioridad.insert({distX[nodo]-peso,nodo,0});
			}
			v[nodo]=true;
			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 274 ms 56656 KB Output is correct
2 Correct 300 ms 60496 KB Output is correct
3 Correct 94 ms 5716 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 348 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 348 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 348 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 -