結果
| 問題 |
No.205 マージして辞書順最小
|
| コンテスト | |
| ユーザー |
tottoripaper
|
| 提出日時 | 2015-05-08 23:29:14 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
AC
|
| 実行時間 | 15 ms / 5,000 ms |
| コード長 | 848 bytes |
| コンパイル時間 | 657 ms |
| コンパイル使用メモリ | 63,864 KB |
| 実行使用メモリ | 5,376 KB |
| 最終ジャッジ日時 | 2024-07-05 20:40:14 |
| 合計ジャッジ時間 | 1,428 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 15 |
ソースコード
// Ω\・8・)チューン
#include <iostream>
#include <algorithm>
std::string S[50];
int main(){
int N;
std::cin >> N;
int L = 0;
for(int i=0;i<N;i++){
std::cin >> S[i];
L += S[i].size();
}
std::string T = "";
std::string *first = S;
for(int i=0;i<L;i++){
std::sort(first, first+N, [](const std::string& lhs, const std::string& rhs){
int l = std::min(lhs.size(), rhs.size());
for(int i=0;i<l;i++){
if(lhs[i] != rhs[i]){
return lhs[i] < rhs[i];
}
}
return lhs.size() > rhs.size();
});
T += (*first)[0];
first->erase(0, 1);
if(first->empty()){
++first; --N;
}
}
std::cout << T << std::endl;
}
tottoripaper