Submission #986695

#TimeUsernameProblemLanguageResultExecution timeMemory
986695beabossFriend (IOI14_friend)C++14
Compilation error
0 ms0 KiB
// Source: https://oj.uz/problem/view/IOI14_friend?locale=en // #include "friend.h" #include "bits/stdc++.h" using namespace std; #define s second #define f first #define pb push_back typedef long long ll; typedef pair<ll, ll> pii; typedef vector<pii> vpii; typedef vector<ll> vi; #define FOR(i, a, b) for (ll i = (a); i<b; i++) bool ckmin(ll& a, ll b){ return b < a ? a = b, true : false; } bool ckmax(ll& a, ll b){ return b > a ? a = b, true : false; } const ll N = 1e5 + 10; ll c[N]; vi adj[N]; int findSample(int n, int confidence[], int host[], int protocol[]) { // int findSample(ll n, vi confidence, vi host, vi protocol) { // vi bst = {0, 0}; // bst[0] += confidence[0]; // c[0] = 0; // FOR(i, 1, n) { // // cout << i << endl; // if (protocol[i] == 2) { // adj[i].pb(host[i]); // adj[host[i]].pb(i); // } // } // vector<bool> vis(n, false); // FOR(i, 0, n) { // // cout << i // if (!vis[i]) { // queue<ll> q; // q.push(i); // vis[i]=true; // ll best = 0; // while (!q.empty()) { // auto cur = q.front(); // q.pop(); // // cout << cur << endl; // best = max(best, (ll) confidence[cur]); // for (auto val: adj[cur]) if (!vis[val]) { // vis[val]=true; // q.push(val); // } // } // // cout << i << best << endl; // confidence[i]=best; // } // } int res = 0; for (int i = n-1; i >= 1; i--) { // cout << ' ' << i << host[i] << protocol[i] << endl; if (protocol[i] == 1) { confidence[host[i]] += confidence[i]; // c[i] = c[host[i]]; // bst[c[i]] += confidence[i]; } else if (protocol[i] == 2) { confidence[host[i]] = max(confidence[host[i]], confidence[i]); // c[i] = !c[host[i]]; // bst[c[i]] += confidence[i]; } else { confidence[host[i]] = max(confidence[host[i]] - confidence[i], 0ll); res += confidence[i]; } // } else { // bst[c[host[i]]] -= confidence[host[i]]; // bst[c[host[i]]] += max(confidence[host[i]], confidence[i]); // } // if (protocol[i] != 2) cout << i << bst[c[i]] << endl; } return res + confidence[0]; } // int main() { // ios::sync_with_stdio(false); // cin.tie(nullptr); // ll n; // cin >> n; // vi c(n); // FOR(i, 0, n) cin >> c[i]; // vi prot(n); // vi host(n); // FOR(i, 1, n) cin >> host[i] >> prot[i]; // cout << findSample(n, c, host, prot) << endl; // }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:82:70: error: no matching function for call to 'max(int, long long int)'
   82 |    confidence[host[i]] = max(confidence[host[i]] - confidence[i], 0ll);
      |                                                                      ^
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 friend.cpp:5:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:254:5: note:   template argument deduction/substitution failed:
friend.cpp:82:70: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   82 |    confidence[host[i]] = max(confidence[host[i]] - confidence[i], 0ll);
      |                                                                      ^
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 friend.cpp:5:
/usr/include/c++/10/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++/10/bits/stl_algobase.h:300:5: note:   template argument deduction/substitution failed:
friend.cpp:82:70: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'long long int')
   82 |    confidence[host[i]] = max(confidence[host[i]] - confidence[i], 0ll);
      |                                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from friend.cpp:5:
/usr/include/c++/10/bits/stl_algo.h:3480:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3480 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3480:5: note:   template argument deduction/substitution failed:
friend.cpp:82:70: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |    confidence[host[i]] = max(confidence[host[i]] - confidence[i], 0ll);
      |                                                                      ^
In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from friend.cpp:5:
/usr/include/c++/10/bits/stl_algo.h:3486:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3486 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/10/bits/stl_algo.h:3486:5: note:   template argument deduction/substitution failed:
friend.cpp:82:70: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   82 |    confidence[host[i]] = max(confidence[host[i]] - confidence[i], 0ll);
      |                                                                      ^