結果
| 問題 |
No.205 マージして辞書順最小
|
| コンテスト | |
| ユーザー |
hashiryo
|
| 提出日時 | 2018-10-20 12:58:52 |
| 言語 | C++11(廃止可能性あり) (gcc 13.3.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,310 bytes |
| コンパイル時間 | 1,320 ms |
| コンパイル使用メモリ | 96,748 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-11-19 02:21:07 |
| 合計ジャッジ時間 | 2,300 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 7 WA * 8 |
ソースコード
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'
#define debugArrayP(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i].first<< " " << x[i].second << '\n'
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;
bool compare(const string& s,const string& t){
if(s[0]!=t[0])return s<t;
if((s.size()==1&&t.size()==1)||(s.size()!=1&&t.size()!=1)){
return s<t;
}
return t.size()==1;
}
int main(){
int N;cin>>N;
vector<string> S(N);
repeat(i,N){
cin>>S[i];
}
string ans;
while(!S.empty()){
sort(S.begin(),S.end(),compare);
ans += S[0][0];
S[0].erase(S[0].begin());
if(S[0].empty())S.erase(S.begin());
}
cout << ans << endl;
return 0;
}
hashiryo