답안 #315921

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
315921 2020-10-24T12:47:23 Z aris12345678 Traffic (IOI10_traffic) C++17
컴파일 오류
0 ms 0 KB
#include "traffic.h"
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pi pair<int, int>
#define f first
#define s second

const int mxN = 1e6+5;
const int mod = 1e9+7;
const int inf = 1e9;

vector<int> adj[mxN];
int res = 0, ans = 0, num = 2e9+5, f[mxN], traf[mxN], pos[mxN];

void dfs(int u, int e) {
    for(int v : adj[u]) {
        if(v == e) continue;
        dfs(v, u);
        traf[u] += traf[v];
        pos[u] = max(pos[u], traf[x]);
    }
    pos[u] = max(pos[u], res-traf[u]-f[u]);
    traf[u] += f[u];
}

int LocateCentre(int n, int p[], int s[], int d[]) {
    for(int i = 0; i < n-1; i++) {
        adj[s[i]].push_back(d[i]);
        adj[d[i]].push_back(s[i]);
        f[i] = p[i];
        res += p[i];
    }
    f[n-1] = p[n-1];
    res += p[n-1];
    dfs(0, -1);
    for(int i = 0; i < n; i++) {
        if(num > pos[i]) { num = pos[i]; ans = i; }
    }
    return ans;
}

Compilation message

traffic.cpp: In function 'void dfs(int, int)':
traffic.cpp:22:35: error: 'x' was not declared in this scope
   22 |         pos[u] = max(pos[u], traf[x]);
      |                                   ^