제출 #559206

#제출 시각아이디문제언어결과실행 시간메모리
559206acm도로 폐쇄 (APIO21_roads)C++14
컴파일 에러
0 ms0 KiB
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3") #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx") #include <bits/stdc++.h> #define FOR(i, l, r) for (int i = (l); i <= (r); ++i) #define REP(i, l, r) for (int i = (l); i < (r); ++i) #define FORD(i, r, l) for (int i = (r); i >= (l); --i) #define REPD(i, r, l) for (int i = (r)-1; i >= (l); --i) #define ll long long #define pii pair<int, int> using namespace std; const int N = 1e5 + 5, Ns4 = 200005; int n; long long ans[N]; long long dpx[N], val[N]; int sz[Ns4]; long long dd[Ns4][2]; vector<pii> S[N]; void DFS(int u, int p, int max_sz) { int now_sz = min(sz[u], max_sz), w = 0; vector<int> Q; long long sum = 0, pre_sum = 0; for (auto [c, v] : S[u]) if (v != p) { DFS(v, u, max_sz); long long xx = dd[v][1] + c; long long yy = dd[v][0]; sum += xx; if (yy - xx < 0) Q.push_back(yy - xx); else w++; } if (w) Q.push_back(0); sort(Q.begin(), Q.end()); pre_sum = 1e15; now_sz = min(now_sz, Q.size()); REP(i, 0, now_sz) { pre_sum = sum; sum += min(0, Q[i]); } Q.clear(); if (now_sz < max_sz) pre_sum = sum; dd[u][0] = pre_sum; dd[u][1] = sum; } void calc(int i) { DFS(0, 0, i); ans[i] = dd[0][1]; } void dnc(int l = 1, int r = n - 2, ll L = ans[n - 1], ll R = ans[0]) { if (l > r) return; if (L == R) { for (int i = l; i <= r; i++) ans[i] = L; return; } int tm = (l + r) / 2; calc(tm); dnc(l, tm - 1, ans[tm], R); dnc(tm + 1, r, L, ans[tm]); } void sub34() { REP(i, 0, n) { sz[i] = S[i].size() - 1; if (i == 0) ++sz[i]; } calc(0); calc(n - 1); if (1 <= n - 2) dnc(); } vector<long long> minimum_closure_costs(int N, vector<int> U, vector<int> V, vector<int> W) { n = N; REP(i, 0, n - 1) { S[U[i]].emplace_back(W[i], V[i]); S[V[i]].emplace_back(W[i], U[i]); } sub34(); vector<long long> ret(n); REP(i, 0, n) ret[i] = ans[i]; return ret; }

컴파일 시 표준 에러 (stderr) 메시지

roads.cpp: In function 'void DFS(int, int, int)':
roads.cpp:23:13: warning: structured bindings only available with '-std=c++17' or '-std=gnu++17'
   23 |   for (auto [c, v] : S[u])
      |             ^
roads.cpp:38:32: error: no matching function for call to 'min(int&, std::vector<int>::size_type)'
   38 |   now_sz = min(now_sz, Q.size());
      |                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from roads.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:
roads.cpp:38:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   38 |   now_sz = min(now_sz, Q.size());
      |                                ^
In file included from /usr/include/c++/10/bits/char_traits.h:39,
                 from /usr/include/c++/10/ios:40,
                 from /usr/include/c++/10/istream:38,
                 from /usr/include/c++/10/sstream:38,
                 from /usr/include/c++/10/complex:45,
                 from /usr/include/c++/10/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:54,
                 from roads.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:
roads.cpp:38:32: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::vector<int>::size_type' {aka 'long unsigned int'})
   38 |   now_sz = min(now_sz, Q.size());
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from roads.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:
roads.cpp:38:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |   now_sz = min(now_sz, Q.size());
      |                                ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from roads.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:
roads.cpp:38:32: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   38 |   now_sz = min(now_sz, Q.size());
      |                                ^