Language: C++

#include <bits/stdc++.h>
#include <iostream>
#include <vector>
using namespace std;
typedef pair <int,int> pii;
int N, M;
vector <pii> bomb;
vector <pii> edge[200005];
int xors[100005];
bool vis[100005];
vector <int> list;

int dfs(int v){
    vis[v] = true;
    int ans = xors[v];
    for (pii e: edge[v]){
        if (!vis[e.first]){
            int res = dfs(e.first);
            if (res == 1){
                list.push_back(e.second);
            }
            ans ^= res;
        }
    }
    return ans;
}

bool cmp(pii a, int b){
    return a.first < b;
}

int main() {
    cin >> N >> M;
    int a, b;
    for (int i=0; i<N; i++){
        scanf("%d %d", &a, &b);
        bomb.push_back({a,b});
    }
    sort(bomb.begin(), bomb.end());
    int l, r;
    for (int i=0; i<M; i++){
        scanf("%d %d", &a, &b);
        l = lower_bound(bomb.begin(), bomb.end(), a, cmp) - bomb.begin();
        r = lower_bound(bomb.begin(), bomb.end(), b+1, cmp) - bomb.begin();
        edge[l].push_back({r, i+1});
        edge[r].push_back({l, i+1});
    }
    xors[0] = bomb[0].second;
    for (int i=1; i<N; i++){
        xors[i] = bomb[i-1].second ^ bomb[i].second;
    }
    xors[N] = bomb[N-1].second;
    memset(vis, false, sizeof(vis));
    for (int i=0; i<N; i++){
        if (!vis[i]){
            int res = dfs(i);
            if (res == 1){
                cout << "-1\n";
                return 0;
            }
        }
    }
    cout << list.size() << endl;
    sort(list.begin(), list.end());
    for (int q: list){
        printf("%d ", q);
    }
    cout << endl;
    return 0;
}


Compiler output:
a.cc: In function 'int dfs(int)':
a.cc:20:17: error: reference to 'list' is ambiguous
   20 |                 list.push_back(e.second);
      |                 ^~~~
In file included from /usr/include/c++/14/list:65,
                 from /usr/include/x86_64-linux-gnu/c++/14/bits/stdc++.h:150,
                 from a.cc:1:
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:11:14: note:                 'std::vector<int> list'
   11 | vector <int> list;
      |              ^~~~
a.cc: In function 'int main()':
a.cc:63:13: error: reference to 'list' is ambiguous
   63 |     cout << list.size() << endl;
      |             ^~~~
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:11:14: note:                 'std::vector<int> list'
   11 | vector <int> list;
      |              ^~~~
a.cc:64:10: error: reference to 'list' is ambiguous
   64 |     sort(list.begin(), list.end());
      |          ^~~~
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:11:14: note:                 'std::vector<int> list'
   11 | vector <int> list;
      |              ^~~~
a.cc:64:24: error: reference to 'list' is ambiguous
   64 |     sort(list.begin(), list.end());
      |                        ^~~~
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:11:14: note:                 'std::vector<int> list'
   11 | vector <int> list;
      |              ^~~~
a.cc:65:17: error: reference to 'list' is ambiguous
   65 |     for (int q: list){
      |                 ^~~~
/usr/include/c++/14/bits/stl_list.h:633:11: note: candidates are: 'template<class _Tp, class _Alloc> class std::__cxx11::list'
  633 |     class list : protected _List_base<_Tp, _Alloc>
      |           ^~~~
a.cc:11:14: note:                 'std::vector<int> list'
   11 | vector <int> list;
      |              ^~~~