結果
問題 |
No.205 マージして辞書順最小
|
ユーザー |
|
提出日時 | 2017-03-14 21:53:04 |
言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 3 ms / 5,000 ms |
コード長 | 569 bytes |
コンパイル時間 | 1,832 ms |
コンパイル使用メモリ | 180,744 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-06-30 00:46:17 |
合計ジャッジ時間 | 2,598 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 15 |
ソースコード
#include <bits/stdc++.h> using namespace std; typedef pair<string, int> P; int main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; vector<string> s(n); for (int i = 0; i < n; i++) cin >> s[i]; priority_queue<P, vector<P>, greater<P> > pq; for (int i = 0; i < n; i++) { s[i] += '}'; pq.push(P(s[i], i)); } string ans = ""; while (!pq.empty()) { P p = pq.top(); pq.pop(); ans += p.first[0]; if (p.first.length() == 2) continue; pq.push(P(p.first.substr(1, p.first.length() - 1), p.second)); } cout << ans << endl; return 0; }