1 solutions
-
3
#include<bits/stdc++.h> using namespace std; const int N=30; vector<string> g[N]; int cnt[N]; int now[N]; int main() { int n,m;cin>>n>>m; for(int i=1;i<=n;i++) { string s;cin>>s; int t=s[0]-'a'; g[t].push_back(s); cnt[t]++; } for(int i=0;i<26;i++) { sort(g[i].begin(),g[i].end()); } while(m--) { char c;cin>>c; int t=c-'a'; cout<<g[t][now[t]]<<endl; now[t]++; if(now[t]==cnt[t]) now[t]=0; } return 0; }
- 1
Information
- ID
- 3479
- Time
- 1000ms
- Memory
- 256MiB
- Difficulty
- 3
- Tags
- (None)
- # Submissions
- 11
- Accepted
- 6
- Uploaded By