Submission #235120

#TimeUsernameProblemLanguageResultExecution timeMemory
235120NONAMEZigZag (COCI17_zigzag)C++17
80 / 80
343 ms6520 KiB
#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 timeMemoryGrader output
Fetching results...