제출 #586528

#제출 시각아이디문제언어결과실행 시간메모리
586528SeDunion친구 (IOI14_friend)C++17
컴파일 에러
0 ms0 KiB
#include "friend.h"
#include<iostream>
#include<assert.h>
#include<vector>

using namespace std;

const int N = 1e5 + 123;

int p[N], q[N];

int findSample(int n,int confidence[],int host[],int protocol[]){
	for (int i = 0 ; i < n ; ++ i) {
		p[i] = confidence[i];
		q[i] = 0;
	}
	for (int y = n - 1 ; y > 0 ; -- y) {
		int x = host[y];
		if (protocol[y] == 0) {
			int np = p[x] + q[y];
			int nq = max(q[x] + p[y], q[x] + q[y]);
			p[x] = np, q[x] = nq;
		} else if (protocol[y] == 1) {
			int np = max({p[x] + p[y], p[x] + q[y], q[x] + p[y]});
			int nq = q[x] + q[y];
			p[x] = np, q[x] = nq;
		} else {
			int np = max(p[x] + q[y], q[x] + p[y]);
			int nq = q[x] + q[y];
			p[x] = np, q[x] = nq;
		}
	}
	return max(p[0], q[0]);
}

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

friend.cpp: In function 'int findSample(int, int*, int*, int*)':
friend.cpp:24:56: error: no matching function for call to 'max(<brace-enclosed initializer list>)'
   24 |    int np = max({p[x] + p[y], p[x] + q[y], q[x] + p[y]});
      |                                                        ^
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: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:24:56: note:   candidate expects 2 arguments, 1 provided
   24 |    int np = max({p[x] + p[y], p[x] + q[y], q[x] + p[y]});
      |                                                        ^
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: 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:24:56: note:   candidate expects 3 arguments, 1 provided
   24 |    int np = max({p[x] + p[y], p[x] + q[y], q[x] + p[y]});
      |                                                        ^