답안 #1080998

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080998 2024-08-29T16:45:20 Z Kipras 봉쇄 시간 (IOI23_closing) C++17
0 / 100
75 ms 29384 KB
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const ll maxN = 2e5+10;

vector<pair<ll, ll>> adj[maxN];

ll been[maxN];

int max_score(int n, int x, int y, long long k, vector<int> U, vector<int> V, vector<int> W){

    for(int i = 0; i <= n; i++)been[i]=0;
    been[x]=1;
    been[y]=1;
    for(int i = 0; i < n-1; i++) {
        adj[U[i]].push_back({V[i], W[i]});
        adj[V[i]].push_back({U[i], W[i]});
    }

    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<>> q;

    for(auto i : adj[x]) {
        q.push(i);
    }
    for(auto i : adj[y]) {
        q.push(i);
    }

    ll res = 0;

    while(!q.empty()) {

        ll v = q.top().first, w = q.top().second;

        if(w>k)break;

        k-=w;
        res++;
        for(auto i : adj[v]) {
            if(been[i.first])continue;
            q.push({i.first, w+i.second});
        }
    }

    return res;

}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 75 ms 29384 KB 1st lines differ - on the 1st token, expected: '451', found: '46293'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '3', found: '1'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 2 ms 4956 KB 1st lines differ - on the 1st token, expected: '6', found: '5'
2 Halted 0 ms 0 KB -