# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
62870 | win11905 | ZigZag (COCI17_zigzag) | C++11 | 335 ms | 13040 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;
vector<string> A[26];
int n, m, cnt[26];
int main() {
cin >> n >> m;
while(n--) {
string ret; cin >> ret;
A[ret[0]-'a'].emplace_back(ret);
}
for(int i = 0; i < 26; ++i) sort(A[i].begin(), A[i].end());
while(m--) {
char c; cin >> c;
cout << A[c-'a'][cnt[c-'a']] << endl;
cnt[c-'a'] = (cnt[c-'a'] + 1) % A[c-'a'].size();
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |