- 图书管理员(数据缺失)
既然没有数据,我就发下AC代码吧。
- 2023-10-6 19:56:58 @
#include<bits/stdc++.h>
using namespace std;
#define int long long
string x;
int a[1005],n,q,len,flag;
void solve()
{
cin>>n>>q;
for(int i=1;i<=n;i++)cin>>a[i];
sort(a+1,a+1+n);
for(int i=1;i<=q;i++)
{
cin>>len>>x;
flag=0;
for(int j=1;j<=n;j++)
{
string b=to_string(a[j]);
if(b.size()<len)continue;
string ss=b.substr(b.size()-len);
if(ss==x)
{
cout<<b<<"\n";
flag=1;
break;
}
}
if(flag==0)cout<<-1<<"\n";
}
}
signed main()
{
ios::sync_with_stdio(false),cin.tie(0),cout.tie(0);
int tt=1;
while(tt--)solve();
return 0;
}
0 comments
No comments so far...
Information
- ID
- 202
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 10
- Tags
- # Submissions
- 7
- Accepted
- 0
- Uploaded By