結果
問題 | No.205 マージして辞書順最小 |
ユーザー |
|
提出日時 | 2019-09-10 22:06:52 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 4 ms / 5,000 ms |
コード長 | 668 bytes |
コンパイル時間 | 1,963 ms |
コンパイル使用メモリ | 181,040 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-02 16:26:14 |
合計ジャッジ時間 | 2,647 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main() { int N; cin >> N; priority_queue<deque<char>, vector<deque<char>>, greater<deque<char>>> pque; for (size_t i = 0; i < N; i++) { string S; cin >> S; deque<char> deq; for (size_t j = 0; j < S.size(); j++) { deq.push_back(S[j]); } deq.push_back('z' + 1); pque.push(deq); } string ans = ""; while (pque.size()) { auto deq = pque.top(); pque.pop(); ans += deq.front(); deq.pop_front(); if (deq.size() > 1) { pque.push(deq); } } cout << ans << endl; }