#include <bits/stdc++.h>
using namespace std;
int main() {
int t;
cin >> t;
for (int i = 0; i < t; ++i) {
int n, m;
cin >> n >> m;
long int ar[n];
for (int j = 0; j < n; ++j) cin >> ar[j];
vector<long> v(ar, ar+n);
sort(v.begin(), v.end());
for (int k = 0; k < m; ++k) {
long b;
cin >> b;
if (binary_search(v.begin(), v.end(), b)) cout << "YES" << endl;
else {
vector<int>::iterator it;
it=lower_bound(v.begin(), v.end(), b);
v.insert(it-v.begin(), b);
cout << "NO" << endl;
}
}
}
return 0;
}
編譯器示出了錯誤,在 '它= LOWER_BOUND(______)' 和 '(它-v.begin()中,b)'。 我無法理解。請幫我整理一下。使用 'LOWER_BOUND'
[Error] no match for 'operator=' (operand types are 'std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}' and '__gnu_cxx::__normal_iterator<long int*, std::vector<long int> >')
[Error] no match for 'operator-' (operand types are 'std::vector<int>::iterator {aka __gnu_cxx::__normal_iterator<int*, std::vector<int> >}' and 'std::vector<long int>::iterator {aka __gnu_cxx::__normal_iterator<long int*, std::vector<long int> >}')
什麼是錯誤信息? –