#include<bits/stdc++.h>
using namespace std;
#define st first
#define nd second
#define pb push_back
typedef long long LL;
vector<string>tab[26];
int pt[26];
int main()
{
ios_base::sync_with_stdio(0);
int k,n;
cin>>k>>n;
for(int i=0;i<k;i++)
{
string t;
cin>>t;
tab[(int)t[0]-'a'].pb(move(t));
}
for(int i=0;i<26;i++)
sort(tab[i].begin(),tab[i].end());
for(int i=0;i<n;i++)
{
char c;
cin>>c;
int kt=(int)c-'a';
cout<<tab[kt][pt[kt]]<<"\n";
if(++pt[kt]==(int)tab[kt].size())
pt[kt]=0;
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
2180 KB |
Output is correct |
2 |
Correct |
0 ms |
2180 KB |
Output is correct |
3 |
Correct |
0 ms |
2180 KB |
Output is correct |
4 |
Correct |
0 ms |
2180 KB |
Output is correct |
5 |
Correct |
0 ms |
2180 KB |
Output is correct |
6 |
Correct |
0 ms |
2180 KB |
Output is correct |
7 |
Correct |
206 ms |
7284 KB |
Output is correct |
8 |
Runtime error |
186 ms |
7380 KB |
Execution timed out (wall clock limit exceeded) |
9 |
Correct |
183 ms |
7396 KB |
Output is correct |
10 |
Correct |
189 ms |
7384 KB |
Output is correct |