Submission #905961

#TimeUsernameProblemLanguageResultExecution timeMemory
905961Amirreza_Fakhri공장들 (JOI14_factories)C++17
Compilation error
0 ms0 KiB
// In the name of the God #include "factories.h" #include <bits/stdc++.h> #define ll long long // #define int long long #define pb push_back #define F first #define S second #define mp make_pair #define pii pair <int, int> #define smin(x, y) (x) = min((x), (y)) #define smax(x, y) (x) = max((x), (y)) #define all(x) (x).begin(), (x).end() using namespace std; const ll inf = (1e9+7)*(1e9+7); const ll mod = 998244353; const ll maxn = 5e5+5; ll n, sz[maxn]; ll mn[maxn]; bool mark[maxn]; vector <pair <ll, ll> > adj[maxn]; vector <pair <ll, ll> > c[maxn]; void dfs1(ll v, ll p) { sz[v] = 1; for (pii e : adj[v]) { ll u = e.F; if (!mark[u] and u != p) { dfs1(u, v); sz[v] += sz[u]; } } } ll dfs2(ll v, ll s, ll p) { for (pii e : adj[v]) { ll u = e.F; if (!mark[u] and u != p and sz[u] > s/2) return dfs2(u, s, v); } return v; } void dfs3(ll v, ll h, ll p, ll b) { c[v].pb(mp(b, h)); for (pii e : adj[v]) { ll u = e.F; if (!mark[u] and u != p) dfs3(u, h+e.S, v, b); } } void cd(ll v) { dfs1(v, v); v = dfs2(v, sz[v], v); dfs3(v, 0, v, v); mark[v] = 1; for (pii e : adj[v]) { ll u = e.F; if (!mark[u]) cd(u); } } void Init(int N, int A[], int B[], int D[]) { n = N; for (ll i = 0; i < n-1; i++) { adj[A[i]].pb(mp(B[i], D[i])); adj[B[i]].pb(mp(A[i], D[i])); } cd(0); fill(mn, mn+n, inf); } ll Query(int S, int X[], int T, int Y[]) { ll ans = inf; for (ll i = 0; i < S; i++) { ll v = X[i]; for (pii p : c[v]) smin(mn[p.F], p.S); } for (ll i = 0; i < T; i++) { ll v = Y[i]; for (pii p : c[v]) smin(ans, mn[p.F]+p.S); } for (ll i = 0; i < S; i++) { ll v = X[i]; for (pii p : c[v]) mn[p.F] = inf; } return ans; }

Compilation message (stderr)

factories.cpp: In function 'long long int Query(int, int*, int, int*)':
factories.cpp:11:38: error: no matching function for call to 'min(long long int&, int&)'
   11 | #define smin(x, y) (x) = min((x), (y))
      |                                      ^
factories.cpp:77:28: note: in expansion of macro 'smin'
   77 |         for (pii p : c[v]) smin(mn[p.F], p.S);
      |                            ^~~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from factories.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:230:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  230 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:230:5: note:   template argument deduction/substitution failed:
factories.cpp:11:38: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   11 | #define smin(x, y) (x) = min((x), (y))
      |                                      ^
factories.cpp:77:28: note: in expansion of macro 'smin'
   77 |         for (pii p : c[v]) smin(mn[p.F], p.S);
      |                            ^~~~
In file included from /usr/include/c++/10/bits/specfun.h:45,
                 from /usr/include/c++/10/cmath:1927,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:41,
                 from factories.cpp:3:
/usr/include/c++/10/bits/stl_algobase.h:278:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  278 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algobase.h:278:5: note:   template argument deduction/substitution failed:
factories.cpp:11:38: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   11 | #define smin(x, y) (x) = min((x), (y))
      |                                      ^
factories.cpp:77:28: note: in expansion of macro 'smin'
   77 |         for (pii p : c[v]) smin(mn[p.F], p.S);
      |                            ^~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from factories.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3468:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3468 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
factories.cpp:11:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   11 | #define smin(x, y) (x) = min((x), (y))
      |                                      ^
factories.cpp:77:28: note: in expansion of macro 'smin'
   77 |         for (pii p : c[v]) smin(mn[p.F], p.S);
      |                            ^~~~
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from factories.cpp:3:
/usr/include/c++/10/bits/stl_algo.h:3474:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3474 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3474:5: note:   template argument deduction/substitution failed:
factories.cpp:11:38: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   11 | #define smin(x, y) (x) = min((x), (y))
      |                                      ^
factories.cpp:77:28: note: in expansion of macro 'smin'
   77 |         for (pii p : c[v]) smin(mn[p.F], p.S);
      |                            ^~~~