제출 #703284

#제출 시각아이디문제언어결과실행 시간메모리
703284bane비밀 (JOI14_secret)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "secret.h"
using namespace std;
typedef long long ll;
const int MAX = 1005;
ll arr[MAX], ret[20][MAX], mask[MAX];
int n;

void Init(int N_, int A[]) {
	n = N_;
	for (int i = 0; i  < n; ++i)arr[i] = A[i];
	
	function<void(int,int,int)>init =  [&](int l, int r, int dep = 0){
		if (l == r) return;
		int m = l+(r-l)/2;
		for(int i = m; i>=l; --i){
			if (i == m){
				ret[dep][i] = arr[i];
			}else{
				ret[dep][i] = Secret(ret[dep][i + 1], arr[i]);
			}
		}
		for (int i = m + 1; i<=r; ++i){
			if (i == m + 1){
				ret[dep][i] = arr[i];
			}else{
				ret[dep][i] = Secret(ret[dep][i - 1], arr[i]);
			}
		}
		for (int i = m + 1; i<=r; ++i)mask[i]^=(1 << dep);
		init(l,m,dep +1);
		init(m+1,r,dep+1);
	};
	init(0,n-1);
}
int Query(int L, int R) {
	int k = __builtin_clz(mask[L] ^ mask[R]);
	return Secret(ret[k][L], ret[k][R]);
}

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

secret.cpp: In function 'void Init(int, int*)':
secret.cpp:34:12: error: no match for call to '(std::function<void(int, int, int)>) (int, int)'
   34 |  init(0,n-1);
      |            ^
In file included from /usr/include/c++/10/functional:59,
                 from /usr/include/c++/10/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/10/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from secret.cpp:1:
/usr/include/c++/10/bits/std_function.h:617:5: note: candidate: '_Res std::function<_Res(_ArgTypes ...)>::operator()(_ArgTypes ...) const [with _Res = void; _ArgTypes = {int, int, int}]'
  617 |     function<_Res(_ArgTypes...)>::
      |     ^~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/c++/10/bits/std_function.h:617:5: note:   candidate expects 3 arguments, 2 provided