Reference to tree is ambiguous in segment tree

  ambiguous, c++, segment-tree

Trying to code segment tree for a very basic question called Range Minimum Query 1 from CSES. Basicly I have to find the minimum number from a range of numbers from an array. But I am getting some ambiguous error can’t understand with it means.

using namespace std;
const int mxN = 2e5+5;
int arr[mxN], tree[4*mxN];
void build(int s, int e, int idx){
    if( s == e){
        tree[idx] = arr[s];
    int mid = s + (e - s)/2;
    build(s, mid, 2*idx);
    build(mid+1, e, 2*idx+1);
    tree[idx] = min(tree[2*idx], tree[2*idx+1]);

int query(int s, int e, int qs, int qe, int idx){
    //fully overlap
    if( qs <= s and e <= qe ){
        return tree[idx];

    //partial overlap
    if( qe < s or qs > e ){
        return 0;

    //partial overlap
    int mid = s + ( e - s)/2;
    int l = query(s, mid, qs, qe, 2*idx);
    int r = query(mid+1, e, qs, qe, 2*idx+1);
    return min(l ,r);

int main(){
    int n, m;
    for(int i = 0; i < n; i++)
    build(0, n-1, 1);
        int qs, we;
        --qs, --qe;
        int ans = query(0, n-1, qs, qe, 1);
    return 0;

Source: Windows Questions C++