# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1025820 | vjudge1 | ZigZag (COCI17_zigzag) | C++17 | 199 ms | 6420 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int const N=2e5+5;
int const mod=1e9+7;
deque<string> wrd[26];
int main(){
int n,m;
cin>>n>>m;
for (int i = 0; i < n; ++i)
{
string s;
cin>>s;
wrd[s[0]-'a'].push_back(s);
}
for (int i = 0; i < 26; ++i)
sort(wrd[i].begin(),wrd[i].end());
for (int i = 0; i < m; ++i)
{
char c;
cin>>c;
string s=wrd[c-'a'][0];
wrd[c-'a'].pop_front();
wrd[c-'a'].push_back(s);
cout<<s<<endl;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |