結果
| 問題 |
No.205 マージして辞書順最小
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2016-08-16 21:38:31 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 3 ms / 5,000 ms |
| コード長 | 635 bytes |
| コンパイル時間 | 877 ms |
| コンパイル使用メモリ | 79,680 KB |
| 実行使用メモリ | 5,248 KB |
| 最終ジャッジ日時 | 2024-11-07 18:22:31 |
| 合計ジャッジ時間 | 1,647 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
#include <iostream>
#include <queue>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
int main() {
int n; cin >> n;
reversed_priority_queue<string> que;
repeat (i,n) {
string s; cin >> s;
s += '\xff';
que.push(s);
}
string ans = "";
while (not que.empty()) {
string t = que.top(); que.pop();
ans += t[0];
if (t.size() != 2) { // 1 is for the sentinel
que.push(t.substr(1));
}
}
cout << ans << endl;
return 0;
}