1 条题解
-
0
#include<bits/stdc++.h> using namespace std; pair<string ,int> a[90030]; bool match(string x,string y){ if (y.length()>x.length()) return 0; return x.substr(0,y.size())==y; } int main(){ int w,n; cin>>w>>n; for (int i=0;i<w;i++){ cin>>a[i].first; a[i].second=i; } sort(a,a+w); while (n--){ string pre; int k; cin>>k>>pre; int pos=k-1+lower_bound(a,a+w,make_pair(pre,0))-a; if (pos>=w || !match(a[pos].first,pre)) { cout<<"-1\n"; continue; } cout<<a[pos].second+1<<'\n'; } return 0; }
- 1
信息
- ID
- 6750
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 9
- 标签
- 递交数
- 69
- 已通过
- 6
- 上传者