Submission #130596

#TimeUsernameProblemLanguageResultExecution timeMemory
130596abacabaFactories (JOI14_factories)C++14
Compilation error
0 ms0 KiB
#include "factories.h" #include <bits/stdc++.h> using namespace std; #define pb push_back #define int long long const int 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], minn[MAX_N]; vector <int> g[MAX_N], d[MAX_N], pCentroid[MAX_N], dCentroid[MAX_N]; 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[v].pb(center); dCentroid[v].pb(dist); for(int i = 0; i < g[v].size(); ++i) { int to = g[v][i]; ll len = d[v][i]; if(!deleted[to] && to != p) dfs(to, v, center, dist + len); } } 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, sz[1])); } long long Query(int S, int X[], int T, int Y[]) { ll ans = inf; for(int i = 0; i < T; ++i) { assert(pCentroid[Y[i]].size() > 30); for(int j = 0; j < pCentroid[Y[i]].size(); ++j) minn[pCentroid[Y[i]][j]] = inf; } for(int i = 0; i < S; ++i) { assert(pCentroid[X[i]].size() > 30); for(int j = 0; j < pCentroid[X[i]].size(); ++j) minn[pCentroid[X[i]][j]] = inf; } for(int i = 0; i < S; ++i) for(int j = 0; j < pCentroid[X[i]].size(); ++j) { int s = pCentroid[X[i]][j]; ll d = dCentroid[X[i]][j]; minn[s] = min(minn[s], d); } for(int i = 0; i < T; ++i) for(int j = 0; j < pCentroid[Y[i]].size(); ++j) { int s = pCentroid[Y[i]][j]; ll d = dCentroid[Y[i]][j]; ans = min(ans, minn[s] + d); } return ans; }

Compilation message (stderr)

factories.cpp:34:36: error: 'll' has not been declared
 void dfs(int v, int p, int center, ll dist = 0) {
                                    ^~
factories.cpp: In function 'void dfs(long long int, long long int, long long int, int)':
factories.cpp:37:19: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i = 0; i < g[v].size(); ++i) {
                 ~~^~~~~~~~~~~~~
factories.cpp:39:3: error: 'll' was not declared in this scope
   ll len = d[v][i];
   ^~
factories.cpp:41:30: error: 'len' was not declared in this scope
    dfs(to, v, center, dist + len);
                              ^~~
factories.cpp:41:30: note: suggested alternative: 'mblen'
    dfs(to, v, center, dist + len);
                              ^~~
                              mblen
factories.cpp: In function 'long long int Query(long long int, long long int*, long long int, long long int*)':
factories.cpp:68:2: error: 'll' was not declared in this scope
  ll ans = inf;
  ^~
factories.cpp:71:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < pCentroid[Y[i]].size(); ++j)
                  ~~^~~~~~~~~~~~~~~~~~~~~~~~
factories.cpp:76:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < pCentroid[X[i]].size(); ++j)
                  ~~^~~~~~~~~~~~~~~~~~~~~~~~
factories.cpp:80:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < pCentroid[X[i]].size(); ++j) {
                  ~~^~~~~~~~~~~~~~~~~~~~~~~~
factories.cpp:82:7: error: expected ';' before 'd'
    ll d = dCentroid[X[i]][j];
       ^
factories.cpp:83:28: error: no matching function for call to 'min(long long int&, std::vector<long long int> [500015])'
    minn[s] = min(minn[s], d);
                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from factories.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:195:5: note: candidate: template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)
     min(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:195:5: note:   template argument deduction/substitution failed:
factories.cpp:83:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<long long int> [500015]')
    minn[s] = min(minn[s], d);
                            ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/istream:38,
                 from /usr/include/c++/7/sstream:38,
                 from /usr/include/c++/7/complex:45,
                 from /usr/include/c++/7/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:52,
                 from factories.cpp:2:
/usr/include/c++/7/bits/stl_algobase.h:243:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)
     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:243:5: note:   template argument deduction/substitution failed:
factories.cpp:83:28: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'std::vector<long long int> [500015]')
    minn[s] = min(minn[s], d);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from factories.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3450:5: note: candidate: template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)
     min(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
factories.cpp:83:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    minn[s] = min(minn[s], d);
                            ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from /usr/include/x86_64-linux-gnu/c++/7/bits/stdc++.h:65,
                 from factories.cpp:2:
/usr/include/c++/7/bits/stl_algo.h:3456:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)
     min(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
factories.cpp:83:28: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
    minn[s] = min(minn[s], d);
                            ^
factories.cpp:86:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   for(int j = 0; j < pCentroid[Y[i]].size(); ++j) {
                  ~~^~~~~~~~~~~~~~~~~~~~~~~~
factories.cpp:88:7: error: expected ';' before 'd'
    ll d = dCentroid[Y[i]][j];
       ^
factories.cpp:89:4: error: 'ans' was not declared in this scope
    ans = min(ans, minn[s] + d);
    ^~~
factories.cpp:89:4: note: suggested alternative: 'abs'
    ans = min(ans, minn[s] + d);
    ^~~
    abs
factories.cpp:91:9: error: 'ans' was not declared in this scope
  return ans;
         ^~~
factories.cpp:91:9: note: suggested alternative: 'abs'
  return ans;
         ^~~
         abs