# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
235120 | NONAME | ZigZag (COCI17_zigzag) | C++17 | 343 ms | 6520 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 sz(x) int(x.size())
#define el '\n'
#define pb push_back
using namespace std;
int n, q, p[26];
vector <string> v[26];
int main() {
cin >> n >> q;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
v[s[0] - 'a'].pb(s);
}
for (int i = 0; i < 26; i++)
sort(v[i].begin(), v[i].end()), p[i] = 0;
while (q--) {
char c;
cin >> c;
cout << v[c - 'a'][(p[c - 'a']++) % sz(v[c - 'a'])] << el;
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |