Submission #914183

# Submission time Handle Problem Language Result Execution time Memory
914183 2024-01-21T10:31:47 Z Ludissey Closing Time (IOI23_closing) C++17
8 / 100
80 ms 25416 KB
#include <bits/stdc++.h>
#include "closing.h"

using namespace std;
#define int long long

vector<vector<pair<int,int>>> edges;

signed max_score(signed N, signed rootX, signed rootY, long long K, std::vector<signed> U, std::vector<signed> V, std::vector<signed> W){
    edges.clear();
    edges.resize(N);
    for (int i = 0; i < N-1; i++)
    {
        edges[U[i]].push_back({V[i], W[i]});
        edges[V[i]].push_back({U[i], W[i]});
    }
    vector<int> visited(N);
    priority_queue<pair<int,int>> krusk;
    krusk.push({0,rootX});
    krusk.push({0,rootY});
    int sum=0;
    int cnt=0;
    while(!krusk.empty()){
        int x=krusk.top().second, sumw=abs(krusk.top().first); krusk.pop();
        if(sum+sumw>K) continue;
        visited[x]=true;
        sum+=sumw;
        cnt++;
        for (auto u : edges[x])
        {
            int v=u.first,w=u.second;
            if(visited[v]) continue;
            krusk.push({-(sumw+w), v});
        }
        
    }
    return (int)cnt;
}
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 77 ms 21760 KB Output is correct
2 Correct 80 ms 25416 KB Output is correct
3 Correct 59 ms 5304 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '30', found: '18'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '30', found: '18'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 1 ms 344 KB 1st lines differ - on the 1st token, expected: '30', found: '18'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 348 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 348 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 348 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 348 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 348 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -