#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fast_io ios_base::sync_with_stdio(0); cin.tie(0)
int main()
{
ios_base::sync_with_stdio(0) ;
cin.tie(0) ;
ll n,m;
cin>>n>>m;
vector<vector<string>>v(26);
string s;
vector<string>t;
for(int i=0; i<n; ++i){
cin>>s;
t.push_back(s);
}
sort(t.begin(),t.end());
for(int i=0; i<n; ++i){
int x = (int)t[i][0]-'a';
v[x].push_back(t[i]);
}
char y;
while(m--){
cin>>y;
ll f = (int)y-'a';
cout<<v[f][0]<<"\n";
v[f].push_back(v[f][0]);
v[f].erase(v[f].begin());
}
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
204 KB |
Output is correct |
2 |
Correct |
0 ms |
204 KB |
Output is correct |
3 |
Correct |
1 ms |
332 KB |
Output is correct |
4 |
Correct |
1 ms |
332 KB |
Output is correct |
5 |
Correct |
1 ms |
332 KB |
Output is correct |
6 |
Correct |
1 ms |
332 KB |
Output is correct |
7 |
Execution timed out |
2089 ms |
10320 KB |
Time limit exceeded |
8 |
Execution timed out |
2096 ms |
10304 KB |
Time limit exceeded |
9 |
Execution timed out |
2084 ms |
10316 KB |
Time limit exceeded |
10 |
Execution timed out |
2080 ms |
10360 KB |
Time limit exceeded |