# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
404025 | penguinhacker | ZigZag (COCI17_zigzag) | C++14 | 58 ms | 7888 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
#define ar array
int n, m, c[26];
vector<string> oc[26];
int main() {
ios::sync_with_stdio(0);
cin.tie(0);
cin >> n >> m;
for (int i=0; i<n; ++i) {
string s;
cin >> s;
oc[s[0]-'a'].push_back(s);
}
for (int i=0; i<26; ++i)
sort(oc[i].begin(), oc[i].end());
while(m--) {
char a;
cin >> a;
int x=a-'a';
cout << oc[x][c[x]] << "\n";
c[x]=(c[x]+1)%oc[x].size();
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |