# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
447308 | dvtd | ZigZag (COCI17_zigzag) | C++14 | 88 ms | 9668 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>
#define ll long long
using namespace std;
vector<string> _list[50];
int idx[50];
int n, m;
int main()
{
cin >> n >> m;
for (int i = 0; i < n; ++i)
{
string tmp; cin >> tmp;
idx[tmp[0] - 'a'] = 0;
_list[tmp[0] - 'a'].push_back(tmp);
}
for (int i = 0; i <= 27; ++i)
sort(_list[i].begin(),_list[i].end());
for (int i = 0; i < m; ++i)
{
char tmp; cin >> tmp;
cout << _list[tmp - 'a'][idx[tmp]] << endl;
idx[tmp] =(idx[tmp] + 1) % (int)(_list[tmp - 'a'].size());
}
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |