제출 #298771

#제출 시각아이디문제언어결과실행 시간메모리
298771super_j6Putovanje (COCI20_putovanje)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <cstdio> #include <algorithm> #include <vector> using namespace std; #define endl '\n' #define ll long long #define pi pair<int, int> #define f first #define s second const int mxn = 200000; int n; int u[mxn], v[mxn], w[mxn], z[mxn]; int vis[mxn], par[mxn], rnk[mxn], p[mxn], dp[mxn]; vector<int> g[mxn]; int fnd(int x){ return x == par[x] ? x : par[x] = fnd(par[x]); } void dfs(int c){ vis[c] = 1, p[c] = par[c] = c; for(int i = c - 1; i <= c + 1; i += 2) if(i >= 0 && i < n && vis[i]){ dp[p[fnd(i)]] -= 2, dp[c]++, dp[i]++; } for(int i : g[c]) if(!vis[c ^ u[i] ^ v[i]]){ if(u[i] != c) swap(u[i], v[i]); dfs(v[i]); int x = fnd(c), y = fnd(v[i]); if(rnk[x] < rnk[y]) swap(x, y); rnk[x] += rnk[x] == rnk[y]; par[y] = x, p[x] = c; } } ll dfs2(int c){ ll ret = 0; for(int i : g[c]) if(u[i] == c){ ret += dfs2(v[i]); dp[c] += dp[v[i]]; ret += min((ll)w[i] * dp[v[i]], z[i]); } return ret; } int main(){ ios::sync_with_stdio(0); cin.tie(0); cin >> n; for(int i = 0; i < n - 1; i++){ cin >> u[i] >> v[i] >> w[i] >> z[i]; g[--u[i]].push_back(i); g[--v[i]].push_back(i); } dfs(0); cout << dfs2(0) << endl; return 0; }

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

putovanje.cpp: In function 'long long int dfs2(int)':
putovanje.cpp:46:39: error: no matching function for call to 'min(long long int, int&)'
   46 |   ret += min((ll)w[i] * dp[v[i]], z[i]);
      |                                       ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from putovanje.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
putovanje.cpp:46:39: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   46 |   ret += min((ll)w[i] * dp[v[i]], z[i]);
      |                                       ^
In file included from /usr/include/c++/9/bits/char_traits.h:39,
                 from /usr/include/c++/9/ios:40,
                 from /usr/include/c++/9/ostream:38,
                 from /usr/include/c++/9/iostream:39,
                 from putovanje.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
putovanje.cpp:46:39: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int')
   46 |   ret += min((ll)w[i] * dp[v[i]], z[i]);
      |                                       ^
In file included from /usr/include/c++/9/algorithm:62,
                 from putovanje.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
putovanje.cpp:46:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   46 |   ret += min((ll)w[i] * dp[v[i]], z[i]);
      |                                       ^
In file included from /usr/include/c++/9/algorithm:62,
                 from putovanje.cpp:3:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
putovanje.cpp:46:39: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   46 |   ret += min((ll)w[i] * dp[v[i]], z[i]);
      |                                       ^