結果

問題 No.205 マージして辞書順最小
ユーザー maine_honzuki
提出日時 2020-12-22 01:29:34
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 9 ms / 5,000 ms
コード長 475 bytes
コンパイル時間 4,168 ms
コンパイル使用メモリ 202,336 KB
最終ジャッジ日時 2025-01-17 06:00:56
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 15
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

int main() {
    int N;
    cin >> N;
    priority_queue<string, vector<string>, greater<>> que;
    for (int i = 0; i < N; i++) {
        string S;
        cin >> S;
        S += 'z' + 1;
        que.push(S);
    }

    string ans;
    while (!que.empty()) {
        string S = que.top();
        que.pop();
        ans += S[0];
        if (S.length() >= 3)
            que.push(S.substr(1));
    }

    cout << ans << endl;
}
0