(UPD: 2024-12-04 14:48 UTC) Judge is not working due to Cloudflare incident. (URL) We can do nothing about it, sorry. After the incident is resolved, we will grade all submissions.

제출 #1123630

#제출 시각아이디문제언어결과실행 시간메모리
1123630marinalucaTraffic (IOI10_traffic)C++20
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "traffic.h" #pragma GCC optimize ("O3") #pragma GCC optimize ("fast-math") #pragma GCC optimize ("unroll-loops") using namespace std; //#define int long long #define ll long long #define all (x) begin(x), end(x) #define xx first #define yy second using pii = pair <int, int>; using tii = tuple <int, int, int>; constexpr int NMAX = (int) 1e6; vector <int> ans[NMAX + 1]; ll lazy[NMAX + 1]; ll cp[NMAX + 1]; ll s, maxi; int rez; inline void dfs (int nod, int parent) { ll maxi = 0; for (auto elem : ans[nod]) { if (elem != parent) { dfs (elem, nod); lazy[nod] += lazy[elem]; maxi = max (maxi, lazy[elem]); } } cp[nod] = maxi; } int LocateCentre(int n,int p[],int s[],int d[]) { maxi = INT_MIN; rez = -1; for (int i = 0; i < n; ++ i) { lazy[i] = p[i]; s += lazy[i]; } for (int i = 0; i < n - 1; ++ i) { ans[s[i]].push_back(d[i]); ans[d[i]].push_back(s[i]); } dfs (0, -1); for (int i = 0; i < n; ++ i) { cp[i] = max (cp[i], s - lazy[i]); if (cp[i] < maxi) { maxi = cp[i]; rez = i; } } return rez; }

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

traffic.cpp: In function 'int LocateCentre(int, int*, int*, int*)':
traffic.cpp:57:21: error: no matching function for call to 'max(long long int&, int*)'
   57 |         cp[i] = max (cp[i], s - lazy[i]);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from traffic.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:254:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  254 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
traffic.cpp:57:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int*')
   57 |         cp[i] = max (cp[i], s - lazy[i]);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/bits/specfun.h:45,
                 from /usr/include/c++/11/cmath:1935,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:41,
                 from traffic.cpp:1:
/usr/include/c++/11/bits/stl_algobase.h:300:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
traffic.cpp:57:21: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and 'int*')
   57 |         cp[i] = max (cp[i], s - lazy[i]);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from traffic.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3461:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3461 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3461:5: note:   template argument deduction/substitution failed:
traffic.cpp:57:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   57 |         cp[i] = max (cp[i], s - lazy[i]);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/11/string:52,
                 from /usr/include/c++/11/bits/locale_classes.h:40,
                 from /usr/include/c++/11/bits/ios_base.h:41,
                 from /usr/include/c++/11/ios:42,
                 from /usr/include/c++/11/istream:38,
                 from /usr/include/c++/11/sstream:38,
                 from /usr/include/c++/11/complex:45,
                 from /usr/include/c++/11/ccomplex:39,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:54,
                 from traffic.cpp:1:
/usr/include/c++/11/bits/stl_algo.h:3467:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3467 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/11/bits/stl_algo.h:3467:5: note:   template argument deduction/substitution failed:
traffic.cpp:57:21: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   57 |         cp[i] = max (cp[i], s - lazy[i]);
      |                 ~~~~^~~~~~~~~~~~~~~~~~~~