結果
問題 |
No.205 マージして辞書順最小
|
ユーザー |
![]() |
提出日時 | 2020-10-17 21:43:20 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 579 bytes |
コンパイル時間 | 2,142 ms |
コンパイル使用メモリ | 179,364 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-21 03:09:21 |
合計ジャッジ時間 | 2,446 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; using ul = unsigned long; using ull = unsigned long long; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); const string G{ 'z' + 1 }; int n; cin >> n; priority_queue<string, vector<string>, greater<string> > pq; for (int i = 0; i < n; ++i) { string s; cin >> s; pq.push(s + G); } stringstream ss; while (!pq.empty()) { string s = pq.top(); ss << s[0]; pq.pop(); if (s.size() > 1 && s.substr(1) != G) pq.push(s.substr(1)); } cout << ss.str() << "\n"; return 0; }