| # | Time | Username | Problem | Language | Result | Execution time | Memory | 
|---|---|---|---|---|---|---|---|
| 170327 | ngmh | ZigZag (COCI17_zigzag) | C++11 | 1080 ms | 12524 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;
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 time | Memory | Grader output | 
|---|---|---|---|---|
| Fetching results... | ||||
