結果
問題 |
No.205 マージして辞書順最小
|
ユーザー |
![]() |
提出日時 | 2015-05-08 23:36:48 |
言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 704 bytes |
コンパイル時間 | 678 ms |
コンパイル使用メモリ | 85,484 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-05 20:42:05 |
合計ジャッジ時間 | 1,363 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 WA * 1 |
other | AC * 5 WA * 10 |
ソースコード
#include<iostream> #include<string> #include<algorithm> #include<functional> #include<vector> #include<stack> #include<queue> #include<set> #include<map> #include<cstdio> #include<cstdlib> #include<cstring> #include<cmath> using namespace std; multiset<string> dict; signed main() { int n, i, j; int sumLen = 0; string s; cin >> n; for( i = 0; i < n; i++ ) { cin >> s; sumLen += s.length(); dict.insert(s); } for( i = 0; i < sumLen; i++ ) { multiset<string>::iterator it = dict.begin(); string cpy = *it; cout << cpy[0]; string dist; for(int j = 1; j < cpy.length(); j++) dist += cpy[j]; dict.erase(*it); if (dist.length() > 0) dict.insert(dist); } return 0; }