# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
381327 | IldarKA | ZigZag (COCI17_zigzag) | C++14 | 462 ms | 12396 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;
int k, n;
set < pair < int, string > > s2[26];
int main(){
cin >> k >> n;
for(int i = 1; i <= k; i++){
string s;
cin >> s;
s2[int(s[0] - 'a')].insert({0, s});
}
for(int i = 1; i <= n; i++){
char a;
cin >> a;
int c = a - 'a';
string ans = s2[c].begin() -> second;
cout << ans << '\n';
int kol = s2[c].begin() -> first;
kol++;
s2[c].erase(s2[c].begin());
s2[c].insert({kol, ans});
}
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |