結果

問題 No.205 マージして辞書順最小
ユーザー buriburi
提出日時 2019-10-13 17:58:10
言語 C++17
(gcc 15.3.0 + boost 1.92.0 + ACL)
コンパイル:
g++-15 -O2 -fplugin=/usr/lib/yukicoder/noavx512-gcc15.so -lm -std=c++17 -Wuninitialized -DONLINE_JUDGE -o a.out _filename_
実行:
./a.out
結果
AC  
実行時間 1 ms / 5,000 ms
+ 824µs
コード長 634 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 666 ms
コンパイル使用メモリ 103,800 KB
実行使用メモリ 9,828 KB
最終ジャッジ日時 2026-10-24 05:40:59
合計ジャッジ時間 2,552 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge6_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

#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;
}
0