yanshuai666 @ 2024-11-16 15:51:39
#include <bits/stdc++.h>
using namespace std;
const int N = 1000010;
int n, m, q[N];
int main()
{
scanf("%d%d", &n, &m);
for (int i = 1; i <= n; i++)
scanf("%d", &q[i]);
while (m--)
{
int x;
scanf("%d", &x);
int l = 1, r = n;
while (l < r)
{
int mid = l + r >> 1;
if (q[mid] >= x)
r = mid;
else
l = mid + 1;
}
if (q[l] != x)
cout << "-1";
else
cout << l << " ";
}
return 0;
}
by SDSXC @ 2024-11-16 16:09:06
cout<<"-1" -1后面没空格