답안 #362306

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
362306 2021-02-02T15:31:45 Z saifu Traffic (IOI10_traffic) C++14
0 / 100
17 ms 23788 KB
// ----- In the name of ALLAH, the Most Gracious, the Most Merciful -----

#include "traffic.h"
#include<bits/stdc++.h>
using namespace std;

#define endl "\n"
#define mod 1000000007
#define inf (int)1e18 

const int mxn = 1e6+10;
vector<int> g[mxn];
int people[mxn];
int dp[mxn];

void dfs(int v, int p=-1){
    dp[v] = people[v];

    for(int u : g[v]){
        if(u==p) continue;
        dfs(u,v);
        dp[v] += dp[u];
    }
}

int LocateCentre (int n, int p[], int d[], int s[]){

    for(int i=0;i<n;i++) people[i] = p[i];

    for(int i=0;i<n-1;i++){
        g[s[i]].push_back(d[i]);
        g[d[i]].push_back(s[i]);
    }

    int mn = inf;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++) dp[i] = 0;
        dfs(i); 
        int mx = 0;
        for(int u : g[i]){
            mx = max(mx,dp[u]);
        }
        mn = min(mn,mx);
    }

    return mn;
}

// int32_t main(){
//     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//     int n; cin >> n;
//     for(int i=0;i<n;i++) cin >> people[i];

//     for(int i=0;i<n-1;i++){
//         int u,v; cin >> u >> v;
//         g[v].push_back(u);
//         g[u].push_back(v);
//     }

    
    
//     return 0;
// }
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB Output is correct
2 Incorrect 16 ms 23788 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB Output is correct
2 Incorrect 16 ms 23788 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB Output is correct
2 Incorrect 16 ms 23788 KB Output isn't correct
3 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 17 ms 23788 KB Output is correct
2 Incorrect 16 ms 23788 KB Output isn't correct
3 Halted 0 ms 0 KB -