# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
170327 | ngmh | ZigZag (COCI17_zigzag) | C++11 | 1080 ms | 12524 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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... |