Submission #130601

#TimeUsernameProblemLanguageResultExecution timeMemory
130601abacabaFactories (JOI14_factories)C++14
Compilation error
0 ms0 KiB
#include "factories.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define ll long long const int L = 23; const ll inf = 2e15; const int MAX_N = 5e5 + 15; const int MAX_Q = 1e6 + 15; const int MAX_SUM_ST = 1e6 + 15; const int MAX_VALUE = 1e9; int n, m, sz[MAX_N], sizeCentroid[MAX_N]; ll minn[MAX_N]; vector <int> g[MAX_N], d[MAX_N]; int pCentroid[MAX_N][L]; ll dCentroid[MAX_N][L]; bool deleted[MAX_N]; void build(int v, int p = -1) { sz[v] = 1; for(auto to : g[v]) if(to != p && !deleted[to]) { build(to, v); sz[v] += sz[to]; } } int centroid(int v, int p, int n) { for(auto to : g[v]) if(!deleted[to] && to != p && sz[to] > n / 2) return centroid(to, v, n); return v; } void dfs(int v, int p, int center, ll dist = 0) { pCentroid[sizeCentroid[v]] = center; dCentroid[sizeCentroid[v]++] = dist; for(int i = 0; i < g[v].size(); ++i) { int to = g[v][i]; if(!deleted[to] && to != p) dfs(to, v, center, dist + d[v][i]); } } void process(int center) { deleted[center] = true; build(center, -1); dfs(center, -1, center); for(int to : g[center]) if(!deleted[to]) process(centroid(to, -1, sz[to])); } void Init(int N, int A[], int B[], int D[]) { n = N; for(int i = 0; i < n; ++i) { g[A[i]].pb(B[i]); d[A[i]].pb(D[i]); g[B[i]].pb(A[i]); d[B[i]].pb(D[i]); } build(1); process(centroid(1, -1, n)); } long long Query(int S, int X[], int T, int Y[]) { ll ans = inf; for(int i = 0; i < T; ++i) { for(int j = 0; j < sizeCentroid[Y[i]]; ++j) minn[pCentroid[Y[i]][j]] = inf; } for(int i = 0; i < S; ++i) { for(int j = 0; j < sizeCentroid[X[i]]; ++j) minn[pCentroid[X[i]][j]] = inf; } for(int i = 0; i < S; ++i) for(int j = 0; j < sizeCentroid[X[i]]; ++j) { int s = pCentroid[X[i]][j]; minn[s] = min(minn[s], dCentroid[X[i]][j]); } for(int i = 0; i < T; ++i) for(int j = 0; j < sizeCentroid[Y[i]]; ++j) { int s = pCentroid[Y[i]][j]; ans = min(ans, minn[s] + dCentroid[Y[i]][j]); } return ans; }

Compilation message (stderr)

factories.cpp: In function 'void dfs(int, int, int, long long int)':
factories.cpp:39:31: error: incompatible types in assignment of 'int' to 'int [23]'
  pCentroid[sizeCentroid[v]] = center;
                               ^~~~~~
factories.cpp:40:33: error: incompatible types in assignment of 'long long int' to 'long long int [23]'
  dCentroid[sizeCentroid[v]++] = dist;
                                 ^~~~
factories.cpp:41:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < g[v].size(); ++i) {
                 ~~^~~~~~~~~~~~~