Submission #999305

# Submission time Handle Problem Language Result Execution time Memory
999305 2024-06-15T09:39:43 Z thelegendary08 Closing Time (IOI23_closing) C++17
8 / 100
136 ms 37064 KB
#include "closing.h"
#include<bits/stdc++.h>
#define f0r(i,n) for(int i = 0;i<n;i++)
#define pb push_back
#define vi vector<int>
#define ll long long int
using namespace std;

int max_score(int N, int X, int Y, long long K,
              std::vector<int> U, std::vector<int> V, std::vector<int> W)
{
    vector<pair<ll,ll>> adj[N];
    f0r(i, N-1){
    	adj[U[i]].pb({V[i], W[i]});
    	adj[V[i]].pb({U[i], W[i]});
    }
    vector<vector<ll>>dist(N, vector<ll>(2, 4e18));
    vector<bool>vis(N, 0);
    queue<int>q;
    q.push(X);
    vis[X] = 1;
    dist[X][0] = 0;
    while(!q.empty()){
    	int c = q.front();
    	q.pop();
    	for(auto u : adj[c]){
    		if(vis[u.first])continue;
    		vis[u.first] = 1;
    		dist[u.first][0] = min(dist[u.first][0], dist[c][0] + u.second);
    		q.push(u.first);
    	}
    }
    f0r(i,N)vis[i] = 0;
    vis[Y] = 1;
    dist[Y][1] = 0;
    q.push(Y);
    while(!q.empty()){
    	int c = q.front();
    	q.pop();
    	for(auto u : adj[c]){
    		if(vis[u.first])continue;
    		vis[u.first] = 1;
    		dist[u.first][1] = min(dist[u.first][1], dist[c][1] + u.second);
    		q.push(u.first);
    	}
    }
    vector<ll> dists;
    f0r(i, N){
    	dists.pb(min(dist[i][0], dist[i][1]));
    }
    sort(dists.begin(), dists.end());
	int ans = 0;
	ll s = 0;
	f0r(i, N){
		if(s + dists[i] > K)break;
		ans++;
		s += dists[i];
	}
	return ans;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 344 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 113 ms 37064 KB Output is correct
2 Correct 136 ms 36984 KB Output is correct
3 Correct 65 ms 5456 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 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 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 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 1 ms 348 KB Output is correct
2 Incorrect 0 ms 348 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 0 ms 344 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 0 ms 344 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 0 ms 344 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 0 ms 344 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 0 ms 344 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -