Submission #381327

#TimeUsernameProblemLanguageResultExecution timeMemory
381327IldarKAZigZag (COCI17_zigzag)C++14
80 / 80
462 ms12396 KiB
#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 timeMemoryGrader output
Fetching results...