답안 #393365

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
393365 2021-04-23T10:05:02 Z huukhang Traffic (IOI10_traffic) C++11
컴파일 오류
0 ms 0 KB
// - Only when necessary :d
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")

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

const ll mod = 1e9 + 7;
const ll inf = 2e9;
const double eps = 1e-9;

int sum = 0;
int a[1000005];
vector<vector<int>> g;
int sz[1000005], congest[1000005];

void dfs(int s, int p) {
	for (auto v : g[s]) {
		if (v != p) {
			dfs(v, s);
			sz[s] += sz[v];
			congest[s] = max(congest[s], congest[v]);
		}
	}

	congest[s] = max(congest[s], sum - sz[s] - a[s]);
	sz[s] += a[s];
}

int LocateCentre(int n, int p[], int s[], int d[]) {
	for (int i = 0; i < n; ++i) a[i] = p[i];

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

	for (int i = 0; i < n; ++i) sum += a[i];

	dfs(0, -1);

	int mn = inf, ans;
	for (int i = 0; i < n; ++i) {
		if (mn > congest[i]) {
			mn = congest[i];
			ans = i;
		}
	}

	return ans;
}

Compilation message

traffic.cpp:9:7: error: 'll' does not name a type
    9 | const ll mod = 1e9 + 7;
      |       ^~
traffic.cpp:10:7: error: 'll' does not name a type
   10 | const ll inf = 2e9;
      |       ^~
traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:44:11: error: 'inf' was not declared in this scope; did you mean 'ynf'?
   44 |  int mn = inf, ans;
      |           ^~~
      |           ynf
traffic.cpp:48:4: error: 'ans' was not declared in this scope; did you mean 'abs'?
   48 |    ans = i;
      |    ^~~
      |    abs
traffic.cpp:52:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   52 |  return ans;
      |         ^~~
      |         abs