Submission #798259

# Submission time Handle Problem Language Result Execution time Memory
798259 2023-07-30T14:26:23 Z QwertyPi Friend (IOI14_friend) C++14
Compilation error
0 ms 0 KB
#include "friend.h"
#include <bits/stdc++.h>

using namespace std;
struct state{
	int p, q;
};

state st[100011];

state f(int ptc, state s, state t){
	if(ptc == 1) return {s.p + t.q, max(s.q + t.p, s.q + t.q)};
	else if(ptc == 2) return {max(max(s.p + t.p), max(s.p + t.q, s.q + t.p)), s.q + t.q};
	else return {max(s.p + t.q, s.q + t.p), s.q + t.q};
}

int findSample(int n, int confidence[], int host[], int protocol[]){
	for(int i = 0; i < n; i++) st[i] = {confidence[i], 0};
	for(int i = n - 1; i >= 1; i--){
		st[host[i]] = f(protocol[i], st[i], st[host[i]]);
	}
	return ans;
}

Compilation message

friend.cpp: In function 'state f(int, state, state)':
friend.cpp:13:45: error: no matching function for call to 'max(int)'
   13 |  else if(ptc == 2) return {max(max(s.p + t.p), max(s.p + t.q, s.q + t.p)), s.q + t.q};
      |                                             ^
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:2:
/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:13:45: note:   candidate expects 2 arguments, 1 provided
   13 |  else if(ptc == 2) return {max(max(s.p + t.p), max(s.p + t.q, s.q + t.p)), s.q + t.q};
      |                                             ^
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:2:
/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:13:45: note:   candidate expects 3 arguments, 1 provided
   13 |  else if(ptc == 2) return {max(max(s.p + t.p), max(s.p + t.q, s.q + t.p)), s.q + t.q};
      |                                             ^
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:2:
/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:13:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   13 |  else if(ptc == 2) return {max(max(s.p + t.p), max(s.p + t.q, s.q + t.p)), s.q + t.q};
      |                                             ^
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:2:
/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:13:45: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
   13 |  else if(ptc == 2) return {max(max(s.p + t.p), max(s.p + t.q, s.q + t.p)), s.q + t.q};
      |                                             ^
friend.cpp:13:85: error: could not convert '{<expression error>, (s.state::q + t.state::q)}' from '<brace-enclosed initializer list>' to 'state'
   13 |  else if(ptc == 2) return {max(max(s.p + t.p), max(s.p + t.q, s.q + t.p)), s.q + t.q};
      |                                                                                     ^
      |                                                                                     |
      |                                                                                     <brace-enclosed initializer list>
friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:22:9: error: 'ans' was not declared in this scope; did you mean 'abs'?
   22 |  return ans;
      |         ^~~
      |         abs