답안 #1012623

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1012623 2024-07-02T12:19:31 Z JakobZorz 봉쇄 시간 (IOI23_closing) C++17
8 / 100
74 ms 32696 KB
#include"closing.h"
#include<vector>
#include<iostream>
#include<queue>
using namespace std;
typedef long long ll;

int n,x,y;
ll k;
vector<pair<int,int>>nodes[200000];
ll distx[200000];
ll disty[200000];

void dfs1(int node,int par,ll*dists){
    for(auto[ne,w]:nodes[node]){
        if(ne==par)
            continue;
        dists[ne]=dists[node]+w;
        dfs1(ne,node,dists);
    }
}

int lvl1(){
    vector<bool>vis(n);
    int res=0;
    ll kr=k;
    priority_queue<pair<ll,int>>q;
    q.push({0,x});
    q.push({0,y});
    vis[x]=true;
    vis[y]=true;
    while(q.size()){
        int node=q.top().second;
        ll cost=-q.top().first;
        q.pop();
        if(cost>kr)
            break;
        res++;
        kr-=cost;
        for(auto[ne,w]:nodes[node]){
            if(vis[ne])
                continue;
            vis[ne]=true;
            q.push({-min(distx[ne],disty[ne]),ne});
        }
    }
    return res;
}

int max_score(int N,int X,int Y,ll K,vector<int>U,vector<int>V,vector<int>W){
    n=N;
    x=X;
    y=Y;
    k=K;
    for(int i=0;i<n;i++){
        distx[i]=0;
        disty[i]=0;
        nodes[i].clear();
    }
    for(int i=0;i<n-1;i++){
        nodes[U[i]].emplace_back(V[i],W[i]);
        nodes[V[i]].emplace_back(U[i],W[i]);
    }
    dfs1(x,x,distx);
    dfs1(y,y,disty);
    
    int res1=lvl1();
    
    return res1;
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 74 ms 28092 KB Output is correct
2 Correct 73 ms 32696 KB Output is correct
3 Correct 37 ms 10064 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 4956 KB Output is correct
2 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '30', found: '17'
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4952 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -