Submission #586312

#TimeUsernameProblemLanguageResultExecution timeMemory
586312SeDunionFriend (IOI14_friend)C++17
Compilation error
0 ms0 KiB
#include "friend.h" #include<iostream> const int N = 1e6 + 123; int dsu[N]; int val[N]; int get(int x) { if (x == dsu[x]) return x; return dsu[x] = get(dsu[x]); } int findSample(int n,int confidence[],int host[],int protocol[]){ for (int i = 0 ; i < n ; ++ i) { dsu[i] = i; val[i] = confidence[i]; } for (int i = 1 ; i < n ; ++ i) { int j = host[i]; int x = get(i), y = get(j); if (x == y) continue; dsu[x] = y; val[y] = max(val[y], val[x]); } int ans = 0; for (int i = 0 ; i < n ; ++ i) { int j = get(i); ans += val[j]; val[j] = 0; } return ans; }

Compilation message (stderr)

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:24:12: error: 'max' was not declared in this scope; did you mean 'std::max'?
   24 |   val[y] = max(val[y], val[x]);
      |            ^~~
      |            std::max
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/ostream:38,
                 from /usr/include/c++/10/iostream:39,
                 from friend.cpp:2:
/usr/include/c++/10/bits/stl_algobase.h:300:5: note: 'std::max' declared here
  300 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~