Submission #1000449

# Submission time Handle Problem Language Result Execution time Memory
1000449 2024-06-17T14:12:18 Z Mardonbekhazratov Closing Time (IOI23_closing) C++17
8 / 100
53 ms 17236 KB
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
#include "closing.h"
#include <queue>
#include <vector>

using namespace std;

#define ff first
#define ss second

vector<vector<pair<int,int>>>v;
vector<bool>vis;

int max_score(int N, int X, int Y, long long K,
              vector<int> U, vector<int> V, vector<int> W){
    v.assign(N,vector<pair<int,int>>(0));
    vis.assign(N,false);
    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]});
    }
    priority_queue<pair<long long,int>>q;
    int ans=2;
    vis[X]=true;
    vis[Y]=true;
    for(auto [z,w]:v[X]) q.push({-w,z});
    for(auto [z,w]:v[Y]) q.push({-w,z});
    while(!q.empty()){
        auto [d,x]=q.top();
        q.pop();
        if(K+d<0){
            break;
        }
        K+=d;
        vis[x]=true;
        ans++;
        for(auto [z,w]:v[x]) if(!vis[z]) q.push({d-w,z});
    }
    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 51 ms 17236 KB Output is correct
2 Correct 53 ms 16724 KB Output is correct
3 Correct 31 ms 2752 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '19'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '19'
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 0 ms 348 KB Output is correct
2 Incorrect 0 ms 348 KB 1st lines differ - on the 1st token, expected: '30', found: '19'
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 -