# include <iostream>
# include <algorithm>
# include <cstring>
using namespace std;
int a[1005], f[1005];
struct Need
{
int l, x;
};
Need s[1005];
bool check(int x, int y)
{
int q = 0;
while (y)
{
q = q * 10 + y % 10;
y /= 10;
}
int p = 0;
while (x)
{
p = p * 10 + x % 10;
x /= 10;
if (p == q)
return true;
}
return false;
}
int main()
{
// freopen("librarian.in", "r", stdin);
// freopen("librarian.out", "w", stdout);
int n, q;
cin >> n >> q;
for (int i = 1; i <= n; i++)
cin >> a[i];
memset(f, true, sizeof(f));
for (int i = 1; i <= q; i++)
cin >> s[i].l >> s[i].x;
sort(a + 1, a + n + 1);
for (int i = 1; i <= q; i++)
{
bool flag = false;
for (int j = 1; j <= n; j++)
{
if (check(a[j], s[i].x) && f[j])
{
flag = true;
f[j] = false;
cout << a[j] << endl;
break;
}
}
if (!flag)
cout << -1 << endl;
}
return 0;
}
哪位大佬能看看,这题哪错了,本地评测错误数据是对的啊