답안 #468735

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
468735 2021-08-29T13:48:43 Z Redmoonautumn Mousetrap (CEOI17_mousetrap) C++17
0 / 100
858 ms 62856 KB
#include <bits/stdc++.h>
using namespace std;

#define int int64_t

vector<vector<int>> graph;

int dfs2(int v, int p){
    priority_queue<int> pq;
    for(auto u:graph[v]){
        if(u==p)continue;
        int x=dfs2(u,v);
        pq.push(x);
    }
    int sum=0;
    int i=0;
    while (!pq.empty()){
        sum++;
        if(i%2)sum+=pq.top();
        i++;
        pq.pop();
    }
    return sum;
}


signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n,t,m;
    cin>>n>>t>>m;
    graph.resize(n);
    t--;
    m--;
    for(int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        a--;
        b--;
        graph[a].push_back(b);
        graph[b].push_back(a);
    }
    int sol=dfs2(m,t);
    cout<<sol<<"\n";
}
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 438 ms 62856 KB Output is correct
2 Correct 336 ms 56596 KB Output is correct
3 Incorrect 858 ms 61268 KB Output isn't correct
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Incorrect 0 ms 204 KB Output isn't correct
2 Halted 0 ms 0 KB -