Submission #414722

# Submission time Handle Problem Language Result Execution time Memory
414722 2021-05-31T05:50:01 Z ackerman Traffic (IOI10_traffic) C++14
Compilation error
0 ms 0 KB
#include <traffic.h>
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <string.h>
#include <assert.h>
#include <math.h>
#include <numeric>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <limits>
#include <limits.h>
#include <iomanip>
#include <algorithm>
using namespace std;

#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define ll long long
#define ull unsigned long long
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define mkp make_pair
#define fi first
#define se second

const int MAX_N = 1e6+2;
vector<int> adj[MAX_N];

int dfs(int u, int p) {
    int ans = 0;
    for(int to : adj[u]) {
        if(to == p) continue;
        ans += dfs(to, u);
    }
    return ans;
}

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]);
    }

    int ans = INT_MAX;
    for(int i = 0; i < n; i++) {
        int max_traffic = INT_MIN;
        for(int to : adj[i]) {
            max_traffic = max(max_traffic, dfs(to, i));
        }
        ans = min(ans, max_traffic);
    }
    return ans;
}

Compilation message

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:51:24: error: 'n' was not declared in this scope
   51 |     for(int i = 0; i < n; i++) {
      |                        ^