Submission #235354

#TimeUsernameProblemLanguageResultExecution timeMemory
235354VEGAnnZigZag (COCI17_zigzag)C++14
80 / 80
188 ms12536 KiB
#include <bits/stdc++.h> #define MP make_pair #define ft first #define sd second using namespace std; set<pair<int, string> > st[26]; string s; int n, k; int main(){ ios_base::sync_with_stdio(0); cin.tie(0); #ifdef _LOCAL freopen("in.txt","r",stdin); #endif // _LOCAL cin >> k >> n; for (int i = 0; i < k; i++){ cin >> s; st[s[0] - 'a'].insert(MP(0, s)); } for (int i = 0; i < n; i++){ char c; cin >> c; int ch = (c - 'a'); pair<int, string> cur = (*st[ch].begin()); cout << cur.sd << '\n'; st[ch].erase(cur); cur.ft++; st[ch].insert(cur); } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...