Submission #170327

#TimeUsernameProblemLanguageResultExecution timeMemory
170327ngmhZigZag (COCI17_zigzag)C++11
80 / 80
1080 ms12524 KiB
#include <bits/stdc++.h> using namespace std; typedef pair<string, long long> pi; struct cool_compare { bool operator() (const pi p, const pi q) const { if(p.first[0] != q.first[0]) return p.first[0] < q.first[0]; else if(p.second != q.second) return p.second < q.second; else return p.first < q.first; } }; long long k, n, b; string x, a; set<pi, cool_compare> words; set<pi, cool_compare>::iterator it; int main(){ cin >> k >> n; for(int i = 0 ; i < k; i++){ cin >> x; words.insert(pi(x, 0)); } for(int i = 0; i < n; i++){ cin >> x; it = words.lower_bound(pi(x, 0)); cout << it->first << "\n"; a = it->first; b = it->second; b++; words.erase(it); words.insert(pi(a, b)); } }
#Verdict Execution timeMemoryGrader output
Fetching results...