# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
42283 | milmillin | ZigZag (COCI17_zigzag) | C++14 | 243 ms | 13872 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <cstdio>
#include <vector>
#include <queue>
#include <string>
#include <iostream>
using namespace std;
struct word {
string x;
int cnt;
};
bool operator< (const word &a, const word&b) {
if (a.cnt!=b.cnt) return a.cnt>b.cnt;
return a.x>b.x;
}
priority_queue<word> qq[30];
int main () {
int k,n;
scanf("%d%d",&k,&n);
string x;
for (int i=0;i<k;i++) {
cin>>x;
qq[x[0]-'a'].push(word{x,0});
}
char xx;
word now;
for (int i=0;i<n;i++) {
scanf(" %c",&xx);
now = qq[xx-'a'].top();
qq[xx-'a'].pop();
cout << now.x << '\n';
now.cnt++;
qq[xx-'a'].push(now);
}
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |