結果
問題 |
No.205 マージして辞書順最小
|
ユーザー |
|
提出日時 | 2021-06-08 10:36:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,064 bytes |
コンパイル時間 | 2,381 ms |
コンパイル使用メモリ | 209,016 KB |
最終ジャッジ日時 | 2025-01-22 04:53:23 |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 7 WA * 8 |
ソースコード
#include <bits/stdc++.h> using namespace std; int main(void) { cin.tie(0); ios::sync_with_stdio(false); string res,s; vector <string> v; int n; priority_queue <pair<pair<char,string>, pair<int, int>>, vector<pair<pair<char,string>, pair<int, int>>>, greater<pair<pair<char,string>, pair<int, int>>>> pque; cin >> n; for (int i = 0; i < n; i++) { cin >> s; v.push_back(s); } for (int i = 0; i < n; i++) { pque.push(make_pair(make_pair(v[i][0],v[i].substr(1)), make_pair(i, 0))); } while (!pque.empty()) { char ch = pque.top().first.first; string s = pque.top().first.second; int now = pque.top().second.first; int idx = pque.top().second.second; pque.pop(); res += ch; if (idx + 1 < v[now].length()) { string t = s.substr(1); if (t.length() == 0) { t = "zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz"; } pque.push(make_pair(make_pair(v[now][idx + 1],t), make_pair(now, idx + 1))); } } cout << res << '\n'; return 0; }