Submission #319903

#TimeUsernameProblemLanguageResultExecution timeMemory
319903gustasonZigZag (COCI17_zigzag)C++14
80 / 80
270 ms12588 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; struct S { string word; int used; bool operator<(S other) const { if (used == other.used) { return word < other.word; } return used < other.used; } }; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int n, m; cin >> n >> m; set<S> s[30]; for(int i = 0; i < n; i++) { string str; cin >> str; s[str[0]-'a'].insert({str, 0}); } while(m--) { char letter; cin >> letter; auto it = s[letter-'a'].begin(); S curr = *it; cout << curr.word << "\n"; s[letter-'a'].erase(it); s[letter-'a'].insert({curr.word, curr.used+1}); // for(auto i : s[letter-'a']) { // cout << i.word << " " << i.used << "\n"; // } // cout << "\n"; } return 0; } //~ check for overflows
#Verdict Execution timeMemoryGrader output
Fetching results...